7

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)

An̲̳̳drew
  • 13,375
  • 13
  • 47
  • 46
FoxyBOA
  • 5,788
  • 8
  • 48
  • 82

2 Answers2

5

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

stacker
  • 68,052
  • 28
  • 140
  • 210
  • 3
    Unfortunately, hbm2ddl ignore both options. So I don't see any alter/create statement in my log file. – FoxyBOA Mar 13 '10 at 08:38
  • 5
    @FoxyBOA for ddl statements you should try : log4j.logger.org.hibernate.tool.hbm2ddl=debug – stacker Mar 13 '10 at 08:45
3

You can also set a debug breakpoint on

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

and see how it goes.

FelixJongleur42
  • 833
  • 7
  • 8