Skip to content

Commit 51fedd6

Browse files
committed
Reinstate support for Hibernate < 5.5
See gh-27352
1 parent 6d50e65 commit 51fedd6

File tree

2 files changed

+6
-5
lines changed
  • spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa
  • spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hibernate52/src/main/resources

2 files changed

+6
-5
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateProperties.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,18 @@ public void setPhysicalStrategy(String physicalStrategy) {
173173

174174
private void applyNamingStrategies(Map<String, Object> properties) {
175175
applyNamingStrategy(properties, AvailableSettings.IMPLICIT_NAMING_STRATEGY, this.implicitStrategy,
176-
SpringImplicitNamingStrategy.class.getName());
176+
() -> SpringImplicitNamingStrategy.class.getName());
177177
applyNamingStrategy(properties, AvailableSettings.PHYSICAL_NAMING_STRATEGY, this.physicalStrategy,
178-
CamelCaseToUnderscoresNamingStrategy.class.getName());
178+
() -> CamelCaseToUnderscoresNamingStrategy.class.getName());
179179
}
180180

181181
private void applyNamingStrategy(Map<String, Object> properties, String key, Object strategy,
182-
Object defaultStrategy) {
182+
Supplier<String> defaultStrategy) {
183183
if (strategy != null) {
184184
properties.put(key, strategy);
185185
}
186-
else if (defaultStrategy != null && !properties.containsKey(key)) {
187-
properties.put(key, defaultStrategy);
186+
else {
187+
properties.computeIfAbsent(key, (k) -> defaultStrategy.get());
188188
}
189189
}
190190

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

0 commit comments

Comments
 (0)