diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java index cbe98e2830..aa7e44f5e1 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java @@ -26,6 +26,7 @@ import org.junit.After; import org.junit.Test; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy; import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy; import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -53,6 +54,18 @@ public class JpaPropertiesTests { } } + @Test + public void hibernate4NoCustomNamingStrategy() throws Exception { + JpaProperties properties = load(HibernateVersion.V4); + Map hibernateProperties = properties + .getHibernateProperties(mockStandaloneDataSource()); + assertThat(hibernateProperties).contains(entry("hibernate.ejb.naming_strategy", + SpringNamingStrategy.class.getName())); + assertThat(hibernateProperties).doesNotContainKeys( + "hibernate.implicit_naming_strategy", + "hibernate.physical_naming_strategy"); + } + @Test public void hibernate4CustomNamingStrategy() throws Exception { JpaProperties properties = load(HibernateVersion.V4, @@ -163,8 +176,7 @@ public class JpaPropertiesTests { ctx.register(TestConfiguration.class); ctx.refresh(); this.context = ctx; - JpaProperties properties = this.context.getBean(JpaProperties.class); - return properties; + return this.context.getBean(JpaProperties.class); } @Configuration diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 03a450aaa6..ef439af961 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1619,18 +1619,16 @@ configuration properties. The most common options to set are: [indent=0,subs="verbatim,quotes,attributes"] ---- - spring.jpa.hibernate.ddl-auto: create-drop - spring.jpa.hibernate.naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy - spring.jpa.database: H2 - spring.jpa.show-sql: true + spring.jpa.hibernate.ddl-auto=create-drop + spring.jpa.hibernate.naming.physical-strategy=com.example.MyPhysicalNamingStrategy + spring.jpa.database=H2 + spring.jpa.show-sql=true ---- -(Because of relaxed data binding hyphens or underscores should work equally well as -property keys.) The `ddl-auto` setting is a special case in that it has different -defaults depending on whether you are using an embedded database (`create-drop`) or not -(`none`). In addition all properties in `+spring.jpa.properties.*+` are passed through as -normal JPA properties (with the prefix stripped) when the local `EntityManagerFactory` is -created. +The `ddl-auto` setting is a special case in that it has different defaults depending on +whether you are using an embedded database (`create-drop`) or not (`none`). In addition +all properties in `+spring.jpa.properties.*+` are passed through as normal JPA properties +(with the prefix stripped) when the local `EntityManagerFactory` is created. See {sc-spring-boot-autoconfigure}/orm/jpa/HibernateJpaAutoConfiguration.{sc-ext}[`HibernateJpaAutoConfiguration`] and {sc-spring-boot-autoconfigure}/orm/jpa/JpaBaseConfiguration.{sc-ext}[`JpaBaseConfiguration`] diff --git a/spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringNamingStrategy.java b/spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringNamingStrategy.java index 1eb7169138..8f7373bd4e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringNamingStrategy.java +++ b/spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringNamingStrategy.java @@ -16,9 +16,7 @@ package org.springframework.boot.orm.jpa.hibernate; -import org.hibernate.Hibernate; import org.hibernate.cfg.ImprovedNamingStrategy; -import org.hibernate.cfg.NamingStrategy; import org.hibernate.internal.util.StringHelper; import org.springframework.util.Assert; @@ -33,10 +31,7 @@ import org.springframework.util.StringUtils; * @author Phillip Webb * @see "http://stackoverflow.com/questions/7689206/ejb3namingstrategy-vs-improvednamingstrategy-foreign-key-naming" * @since 1.2.0 - * @deprecated as of 1.4 since {@link NamingStrategy} is no longer used by - * {@link Hibernate}. Consider using {@link SpringPhysicalNamingStrategy} */ -@Deprecated @SuppressWarnings("serial") public class SpringNamingStrategy extends ImprovedNamingStrategy {