Query String Logging with Parameter Values in Hibernate
Problem:
Can Hibernate display generated SQL queries with actual parameter values instead of question marks? If not, how can these queries be printed with real values?
Solution:
Using Hibernate Logging:
Enable logging for the following categories:
# Logs SQL statements log4j.logger.org.hibernate.SQL=debug # Logs JDBC parameters log4j.logger.org.hibernate.type=trace
Using P6Spy JDBC Proxy Driver:
As an alternative to Hibernate logging, the P6Spy JDBC proxy driver can be used. This driver intercepts JDBC calls and logs them with detailed information, including parameter values.
The above is the detailed content of How Can I Log Hibernate SQL Queries with Parameter Values?. For more information, please follow other related articles on the PHP Chinese website!