2

how can I export Hibernate data to SQL statements, so that I might reimport them. The data consists of mapped Entities, with Strings, Enums, Integers etc.

I would need an export like: insert into XX (...)

Or similar which I could easily rewrite. Is there anything I could use yet?

ty

3
  • Can you be more specific . What kind of data you want to use? Commented Apr 8, 2012 at 19:13
  • What database are you using? MySQL? Commented Apr 8, 2012 at 19:21
  • I'm not sure if this is what you looking for but you can look this section 10.9 docs.jboss.org/hibernate/orm/3.3/reference/en/html/… Commented Apr 8, 2012 at 19:38

2 Answers 2

2

You can enable query logging by putting

<property name="hibernate.show_sql">true</property>

it will print all the statements executed by hibernate, that you can reuse. I normally use that to verify queries in my toad.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried this before, but the problem is it prints out eg insert into (..) values (?, ?, ?) so I still have to fill the fields manually.
Two ways you can solve this issue, either enable logging for parameter binding and check which parameter values are binded to sql statements. Or else You can use p6spy and configure it as your proxy database driver. It will print all the executed sql statements with parameters.
0

If you are looking to migrate you data to another MySQL server you should be using mysqldump: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.