Affects: 2.3.2.RELEASE
The following property in application.yml
is ignored:
spring.jpa.properties.hibernate.cache.use-query-cache: true
While the following one is correctly taken into account:
spring.jpa.properties.hibernate.cache.use_query_cache: true
I can verify this by setting spring.jpa.show-sql: true
and seeing no queries logged with the second property on subsequent calls to repository methods, but queries logged with the first property after their results should have been cached.
I was expecting both versions to work thanks to relaxed binding.
Comment From: snicoll
I was expecting both versions to work thanks to relaxed binding.
Unfortunately, that's the wrong expectation. The documentation for this property is "Additional native properties to set on the JPA provider.".
There are "native properties" and, as such, have to be defined with the exact same case as what Hibernate expects. Relaxed binding work when binding to @ConfigurationProperties
, it can't infer the case a third party library expects.
Comment From: inad9300
Thanks for your prompt reply and explanation. I hadn't gathered that from the docs. Now I'm scared that some of the properties I'm setting using dashes are being ignored too... Would you happen to have any recommendation on how to verify the correctness of all properties efficiently? Is there, for example, a list somewhere of non-native properties, or one directly of properties to which relaxed binding applies?
Comment From: snicoll
Would you happen to have any recommendation on how to verify the correctness of all properties efficiently?
When you have a configuration property that exposes a Map
type where the key is the id of a property and the value the value you want to set, you should refer to whatever library is being configured. In this particular case, the Hibernate documentation should give you the properties they support and their format.
Taking a step back, if you're configuring something Spring Boot doesn't know about (that's what advanced properties are for vs a dedicated property with a dedicated name) you shouldn't expect relaxed binding to work: the whole point of it is to allow several formats to bind to a dedicated property. Its goal isn't to translate to the format of a third party lib.