0

Does anyone know how to automatically generate an INSERT script (.sql) file when a entity is persisted in hibernate. I dont want to save the whole hibernate log, just when a specific entity is persisted it should generate the script. I also want to append all inserts to the same script file. The script is then going to be runned on another database server.

Is there any easy way to do this? Maybe hibernate anotations/properties?

Mattias S. Nordell
  • 53
  • 1
  • 1
  • 10

1 Answers1

1

From here (Hibernate show real SQL) I found the lib P6Spy, that allows you to get the real SQL output from hibernate to the application log: http://www.mkyong.com/hibernate/how-to-display-hibernate-sql-parameter-values-solution/

With those real SQL's on you log you could make a process to parse the log in order to get only the "INSERT" statements.

It's not a cool solution with annotations but I can't figure out other way to achieve that.

spekdrum
  • 1,559
  • 2
  • 11
  • 15