Springboot : Show slow sql hibernate query properties not working as expected

257 Views Asked by At

I am using the below properties in application.properties file

spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.show-sql=true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=trace
spring.datasource.health.validation-query=SELECT 1
logging.level.org.hibernate.SQL_SLOW=DEBUG
spring.jpa.properties.hibernate.session.events.log.LOG_QUERIES_SLOWER_THAN_MS=5000
server.error.whitelabel.enabled=false
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration

and as expected i want to print the hibernate query which is taking more than 5second(spring.jpa.properties.hibernate.session.events.log.LOG_QUERIES_SLOWER_THAN_MS=5000) to execute. But in the log, all queries are printing. Example.

2023-09-26 18:24:10,136 DEBUG org.hibernate.SQL                        | select lifecyclet0_.LIFECYCLE_TRANSITION_ID as lifecycl1_26_, lifecyclet0_.FROM_LIFECYCLE_STATE_ID as from_lif2_26_, lifecyclet0_.TO_LIFECYCLE_STATE_ID as to_lifec3_26_ from catmp6.LIFECYCLE_TRANSITIONS lifecyclet0_ where lifecyclet0_.FROM_LIFECYCLE_STATE_ID=?
2023-09-26 18:24:10,137 TRACE o.h.type.descriptor.sql.BasicBinder      | binding parameter [1] as [BIGINT] - [4]

Can anyone suggest what is wrong here.

<spring.boot.version>2.7.2</spring.boot.version>
<psql.jdbc.version>42.5.1</psql.jdbc.version>
0

There are 0 best solutions below