How to set hibernate.format_sql in spring-boot?
JavaSpringSpring BootSpring Data-JpaJava Problem Overview
I'm using spring-boot
autoconfiguration for database injection, with properties defined:
spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
But how can I set the hibernate.format_sql=true
? Is that not supported by spring boot?
Java Solutions
Solution 1 - Java
Spring Boot will let you set any available hibernate property using:
spring.jpa.properties.*
So spring.jpa.properties.hibernate.format_sql=true
would work as well.
Check out this part of the documentation
Solution 2 - Java
If you are using yml
format to declare Spring Boot properties, you can use:
spring:
datasource:
jpa:
properties:
hibernate.format_sql: true
Solution 3 - Java
jpa:
hibernate:
ddl-auto: update
show-sql: true
properties:
hibernate.format_sql: true
Solution 4 - Java
This is very much available
spring.jpa.hibernate.format_sql=true
Solution 5 - Java
You can use : spring.jpa.properties.hibernate.format_sql=true
Apart from the documentation, I do follow example from here to configure my application. You can find a sample of properties being used in that.