Hibernate: hibernate.hbm2ddl.auto = update show generated sql

I want to go to Hibernate SessionFactory

hibernate.hbm2ddl.auto=update 

and see the SQL files created in the log file. Is this possible without java coding (you know how to achieve the result using SchemaExport , but we hope that the sleep mode has "in the window")

+6
java hibernate hbm2ddl
source share
2 answers

You can configure logging on System.out with

  • SessionFactory sf = new Configuration().setProperty("hibernate.show_sql", "true")

  • or log4j

     log4j.logger.org.hibernate.SQL=DEBUG, SQL_APPENDER log4j.additivity.org.hibernate.SQL=false 

EDIT: Perhaps this is also useful. Writing to Hibernate sql with values

+5
source share

You can also set the debug breakpoint to

 org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(boolean, boolean) 

and see how this happens.

+3
source share

All Articles