Hibernate show real SQL
log4j.properties
log4j.logger.org.hibernate=INFO, hb
log4j.logger.org.hibernate.SQL=DEBUG
log4j.logger.org.hibernate.type=TRACE
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
hibernate.cfg.xml
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
persistence.xml
Some frameworks use persistence.xml
:
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true"/>
P6Spy does not log hibernate update with HSQLDB
I had the same problem. For me it was because hibernate added the updates into a batch and by default batch calls are not logged in p6spy. Update the p6spy properties, so batch is logged.
spy.properties
#list of categories to exclude: error, info, batch, debug, statement,
#commit, rollback and result are valid values
#excludecategories=
excludecategories=info,debug,result
Related Topics
Renaming a Column in Ms SQL Server 2005
Spark Dataframe Nested Case When Statement
Find the Maximum Consecutive Years for Each Id's in a Table(Oracle SQL)
How to Replace Null Values with a Text
Update Query If Statement for Oracle
Oracle Dynamic Desc and Asc in Order By
SQL - Conditional Where Clause
JSON Without Array Wrapper on Lower Levels
Find Duplicate Records Based on Two Columns
"Ambiguous Column Name" Error on One Particular Server
Make H2 Treat Quoted Name and Unquoted Name as the Same
What's a Zip Join? Have You Ever Heard of That, or a Pairwise Join
Search All Databases for Value
Strategies for Checking Isnull on Varbinary Fields
Postgresql Update Multiple Tables in Single Query
Order by Maximum Condition Match