2
logging:
  level:
    org.hibernate.SQL: debug
    org.hibernate.type: trace

It is part of my application.yml config.
And I was curios about org.hibernate.type option.
So, I have found the information about this.
I could only find this link. jboss doc

I found this option is for tracing binding parameters by programming myself.
However, I want doc or specific explanation.

JinYeong Kim
  • 139
  • 1
  • 7

2 Answers2

2

You can use

logging:
  level:
    org:
      hibernate:
        type: trace   #For prepared statements   

in order to see the values of the data injected (the binding parameters) into the prepared statement.

Instead of just seeing question marks ('?'):

Hibernate: 
insert 
into
    persons
    (age, name, id) 
values
    (?, ?, ?)

you can see the actual data injected in the binding parameters:

2022-12-07 09:30:41.889 TRACE 8004 [main] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [INTEGER] - [10]
2022-12-07 09:30:41.890 TRACE 8004 [main] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [VARCHAR] - [Tom]
2022-12-07 09:30:41.891 TRACE 8004 [main] o.h.type.descriptor.sql.BasicBinder : binding parameter [3] as [BIGINT] - [12]

This way you can see that:

the first  "?" will get the value of 10
the second "?" will get the value of 'Tom'
the third  "?" will get the value of 12

From https://stackoverflow.com/a/63167967/2623162 and https://howtodoinjava.com/spring-boot/spring-data-jpa-sql-logging/

ANOTHER OPTION from https://www.baeldung.com/hibernate-logging-levels is to have these in the logback.xml file (or log4j2 if you use log4j2):

<logger name="org.springframework.data.repository.CrudRepository" level="TRACE"/>
<logger name="org.hibernate.type.descriptor.sql" level="TRACE" />
Alex
  • 1,066
  • 2
  • 9
  • 15
1

Your application.yml contains logger configuration. It states that all classes in package org.hibernate.SQL will have log level debug unless the log level is not defined more specifically, i.e. configuring log level for org.hibernate.SQL.XXX will override log level inherited from org.hibernate.SQL.

There are multiple log levels: error, warn, info, debug, trace.

  • Message with level error has maximum importance so it will be printed always (unless you disable logging at all).
  • Message with level info will be printed if class log level is one of info, debug, trace.
  • Message with level trace has near to zero importance: it will be printed if and only if log level is set to trace.

The link you provided gives enough details to understand what will be logged. To check real logs you have to run your application and execute some SQL query using Hibernate.