Created
December 16, 2011 15:04
-
-
Save rponte/1486381 to your computer and use it in GitHub Desktop.
some ways to show sql generated by hibernate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Setting the hibernate.show_sql to true tells hibernate to Write all SQL statements to console. This is an alternative to setting the log category org.hibernate.SQL to debug. | |
So even if you set this property to false, make sure that you don't have the following category defined (or configured to use a console appender): | |
log4j.logger.org.hibernate.SQL=DEBUG | |
Also, make sure that you don't set the hibernate.show_sql programmatically to true when instancing your Configuration object. Hunt something like this: | |
Configuration cfg = new Configuration().configure(). | |
.setProperty("hibernate.show_sql", "true"); | |
Note that the setProperty(String propertyName, String value) takes as first parameter the full name of a configuration property i.e. hibernate.show_sql, not just show_sql. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<property name="show_sql">true</property> | |
<property name="format_sql">true</property> | |
<property name="use_sql_comments">true</property> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log4j.logger.org.hibernate=INFO, hb | |
log4j.logger.org.hibernate.SQL=DEBUG ## is equivalent to hibernate.show_sql=true | |
log4j.logger.org.hibernate.type=TRACE ## allows you to see the binding parameters | |
log4j.logger.org.hibernate.hql.ast.AST=info | |
log4j.logger.org.hibernate.tool.hbm2ddl=warn | |
log4j.logger.org.hibernate.hql=debug | |
log4j.logger.org.hibernate.cache=info | |
log4j.logger.org.hibernate.jdbc=debug | |
log4j.appender.hb=org.apache.log4j.ConsoleAppender | |
log4j.appender.hb.layout=org.apache.log4j.PatternLayout | |
log4j.appender.hb.layout.ConversionPattern=HibernateLog --> %d{HH:mm:ss} %-5p %c - %m%n | |
log4j.appender.hb.Threshold=TRACE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can show DDL generated by SchemaExport with this:
log4j.logger.org.hibernate.tool.hbm2ddl=debug