Spring data jpa format_sql does not format query

Viewed 291

I am working on a spring data jpa project and need some help formatting the sql statements which are being logged. Here are the properties I used and tried, some are working, others are ignored as indicated. Also some other stuff I have tried

#works
spring.jpa.hibernate.ddl-auto=validate

#works
spring.jpa.show-sql=true   

#ignored 
spring.jpa.properties.hibernate.format_sql=true  
spring.jpa.properties.hibernate_format_sql=true  
spring.jpa.properties.format_sql=true  
spring.jpa.hibernate.format_sql=true  
spring.jpa.format_sql=true  

#ignored 
spring.jpa.properties.hibernate.type=trace 

I found on several stackoverflow questions and other sites saying that " spring.jpa.properties.hibernate.format_sql=true " should work, but here it is ignored. In the documentation in the list of properties it is not listed: https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#appendix.application-properties.data According to https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#data.sql.jpa-and-spring-data.creating-and-dropping hibernate properties should be set with spring.jpa.properties.hibernate...

The project, does not have other hibernate configuration except the hibernate core dependency in pom.xml , which is needed . Here are the two relevant dependencies in pom:

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
</dependency>

spring data jpa is version 2.5.6 , hibernate 5.4.32

Is there anything I can do to be able to format the sql statements with spring.jpa properties ? Thank you!

LE: I have debugged the code and saw that the entitymanager has the hibernate.format_sql=true property.

0 Answers
Related