How to show SQL statements and parameters with Hibernate

Posted by Java developer blog on July 26, 2020

Overview

Sometimes you may want to debug your SQL queries that are generated by Hibernate. In the post, we are going to discuss how to show SQL statements and parameters with Hibernate.

Enable ability to show SQL statements and parameters

Simple add the following code to the application.properties file:

1
2
3
4
5
# Show sql statement
logging.level.org.hibernate.SQL=debug

# Show sql parameters
logging.level.org.hibernate.type.descriptor.sql=trace

Conclusion

We have discussed how to show SQL statements and parameters with Hibernate.