I'm using Spring Boot with Java config. How do I enable hibernate.generate_statistics? I already do have:
logging.level.org.hibernate.stat: INFO
So I tried adding the following config props, and none of these worked:
spring.jpa.hibernate.properties.generate_statistics: true
spring.jpa.hibernate.properties.generate-statistics: true
spring.jpa.hibernate.generate-statistics: true
spring.jpa.hibernate.generate_statistics: true
hibernate.generate-statistics: true
hibernate.generate_statistics: true
The only thing that did work was adding:
-Dhibernate.generate_statistics=true
to the command line. However, for my use case, I prefer to configure this within the Java application itself or properties file in its JAR, not externally on the command line.
Another solution I see is I can also add a "hibernate.properties" file to my classpath, with the contents
hibernate.generate_statistics=true
And that does indeed work. But is it ideal?
According to the documentation, to set a native property on the JPA provider, you can use:
spring.jpa.properties.*= ...
So for hibernate.generate_statistics
, use:
spring.jpa.properties.hibernate.generate_statistics=true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With