Wednesday, July 7, 2021

How to print a query string with parameter values when using Hibernate

 You need to enable logging for the following categories:

org.hibernate.SQL   - set to debug to log all SQL DML statements as they are executed

org.hibernate.type - set to trace to log all JDBC parameters

In case of spring boot is being used, just config this :


aplication.yml

logging:
  level:
    org.hibernate.SQL: DEBUG
    org.hibernate.type: TRACE

aplication.properties

logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type=TRACE

No comments:

Post a Comment