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?
views:
27answers:
1
+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
2010-06-14 21:48:26
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
2010-06-14 21:57:33
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
2010-06-14 22:05:25