Saturday, March 3, 2018

Printing Hibernate generated SQL statements

In logging file (log4j2.xml) enable hibernate loggers:
 
 <Logger name="log4j.logger.org.hibernate.SQL" level="debug" />
 <Logger name="log4j.logger.org.hibernate.type.descriptor.sql" level="trace" />
In persistence.xml turn on printing and formatting SQL statments:
 <property name="hibernate.show_sql" value="true" />
 <property name="hibernate.use_sql_comments" value="true" />
 <property name="hibernate.format_sql" value="true" />

No comments:

Post a Comment