0 votes
1 view
in Java by (2.6k points)

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 it is not possible with Hibernate API?

1 Answer

0 votes
by (46.1k points)

You require to permit logging for the following categories:

  • org.hibernate.SQL   - set to debug to log all SQL DML records as they are executed
  • org.hibernate.typesetet to follow to log all JDBC parameters

So a log4j configuration could seem like:

# logs the SQL statements


# Logs the JDBC parameters passed to a query


The first is similar to hibernate.show_sql=true legacy property, the second prints the bound parameters between other things.

Another resolution (not hibernate based) would be to use a JDBC proxy operator like P6Spy.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !