Video in progress

How do you see the SQL queries and parameters Hibernate is sending?

The simplest way is to set the org.hibernate.SQL logger to DEBUG, and for parameter values set org.hibernate.orm.jdbc.bind to TRACE (Hibernate 6). show-sql=true works too, but it uses System.out, not a logger.

📖 Answer

logging:
  level:
    org.hibernate.SQL: DEBUG
    org.hibernate.orm.jdbc.bind: TRACE   # which value went in place of each ?
spring:
  jpa:
    properties:
      hibernate.format_sql: true

In Hibernate 5 the parameter logger was different: org.hibernate.type.descriptor.sql.BasicBinder. If you copy from old articles, nothing is printed in Hibernate 6, and people lose a lot of time here.

Why a logger instead of show-sql: it goes to the log file, respects the log level, uses the format you want, and on prod you can turn it on with a single setting if needed.

If you need to know the number of queries:

spring.jpa.properties.hibernate.generate_statistics=true

At the end of each session it prints how many queries ran and how long they took.

Don't leave SQL logging on permanently in prod. The log volume grows very fast, and personal data (the parameters) ends up in it.