views:

27

answers:

1

Does Hibernate log the values that it assigns to placeholders in prepared SQL statements? How can configure Log4j so that it writes these values to my log files?

+1  A: 

Yes it does (see the Chapter 3.5 Logging). Activate logging of the following categories:

log4j.logger.org.hibernate.SQL=DEBUG
log4j.logger.org.hibernate.type=TRACE
Pascal Thivent
Except that you end up with a query with a bunch of ? marks, and a ton of lines below where the parameters are spit out. So good, but not perfect. I had to end up writing an aspect to capture the SQL so I could properly log it in executable form...
bwawok
Thank you! http://ahoehma.wordpress.com/2009/06/03/hibernate-sql-logging-with-values/ explains how to use JDBC Logger (http://jdbclogger.sourceforge.net/) to log SQL statements including values of bind parameters.
Derek Mahar