66

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?

membersound
  • 81,582
  • 193
  • 585
  • 1,120

6 Answers6

144

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

geoand
  • 60,071
  • 24
  • 172
  • 190
22

If you are using yml format to declare Spring Boot properties, you can use:

spring:
  datasource:
  jpa:
    properties:
      hibernate.format_sql: true
Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96
16
jpa:
  hibernate:
    ddl-auto: update
  show-sql: true
  properties:
    hibernate.format_sql: true
slfan
  • 8,950
  • 115
  • 65
  • 78
xiaogege
  • 161
  • 1
  • 2
9

This is very much available

spring.jpa.hibernate.format_sql=true
Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116
  • OK thanks. I wonder why http://docs.spring.io/spring-boot/docs/1.1.5.RELEASE/reference/htmlsingle/ does not mention this property though... – membersound Sep 08 '14 at 08:56
7

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.

Vinay Veluri
  • 6,671
  • 5
  • 32
  • 56
0

Follow this below properties

spring.jpa.properties.hibernate.format_sql=true

    #Turn Statics On
    spring.jpa.properties.hibernate.generate_statistics=true
    logging.level.org.hibernate.stat=debug
    
    #Show all queries
    spring.jpa.show-sql=true
    spring.jpa.properties.hibernate.format_sql=true
    logging.level.org.hibernate.type=trace
Lova Chittumuri
  • 2,994
  • 1
  • 30
  • 33