Question

I wish to pass to Hibernate's SessionFactory

hibernate.hbm2ddl.auto=update

and see in log file generated sql statements. Is it possible w/o java coding (know how to achieve the result with SchemaExport, but hope that hibernate has "in box" solution)

Was it helpful?

Solution

You could setup logging to System.out using

  • 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: This maybe also helpful Hibernate sql logging with values

OTHER TIPS

You can also set a debug breakpoint on

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

and see how it goes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top