Hi
Is it possible in hibernate to print generated sql queries with real values instead of question marks?
How would you suggest to print queries with real values if its not possible with hibernate api?
Umar
Hi
Is it possible in hibernate to print generated sql queries with real values instead of question marks?
How would you suggest to print queries with real values if its not possible with hibernate api?
Umar
turn on the org.hibernate.type
Logger to see how the actual parameters are bind to the question marks.
You need to enable logging for the the following categories at debug
and trace
levels respectively:
org.hibernate.SQL
- Log all SQL DML statements as they are executedorg.hibernate.type
- Log all JDBC parametersSo a log4j configuration could look like:
# logs the SQL statements
log4j.logger.org.hibernate.SQL=debug
# Logs the JDBC parameters passed to a query
log4j.logger.org.hibernate.type=trace
The first is equivalent to hibernate.show_sql=true
legacy property, the second prints the bound parameters among other things.
Another solution (non hibernate based) would be to use a JDBC proxy driver like P6Spy.
if you are using hibernate 3.2.xx use
log4j.logger.org.hibernate.SQL=trace
instead of
log4j.logger.org.hibernate.SQL=debug