61

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
  • 74,158
  • 163
  • 522
  • 986

5 Answers5

134

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
  • 54,228
  • 18
  • 157
  • 171
16

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

spring:
  datasource:
  jpa:
    properties:
      hibernate.format_sql: true
Andrii Abramov
  • 8,945
  • 8
  • 66
  • 87
14
jpa:
  hibernate:
    ddl-auto: update
  show-sql: true
  properties:
    hibernate.format_sql: true
slfan
  • 8,665
  • 115
  • 63
  • 77
xiaogege
  • 141
  • 1
  • 2
9

This is very much available

spring.jpa.hibernate.format_sql=true
Ankur Singhal
  • 25,030
  • 13
  • 76
  • 111
  • 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
6

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,317
  • 5
  • 30
  • 54