Continue to support spring.jpa.hibernate.namingstrategy
In 1.0, the property spring.jpa.hibernate.namingstrategy could be used to configure Hibernate's naming strategy. This was at odds with most other configuration where binding to namingStrategy would require a property with some indication that it was two separate words, for example: naming-strategy, naming_strategy, or namingStrategy This commit adds a new setter, setNamingstrategy, to JpaProperties so that an app that was using namingstrategy in 1.0 continues to work in 1.1. Issue #928
This commit is contained in:
parent
1a475102de
commit
aaa5b9ddf1
|
@ -30,6 +30,7 @@ import org.springframework.orm.jpa.vendor.Database;
|
|||
* External configuration properties for a JPA EntityManagerFactory created by Spring.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.jpa")
|
||||
|
@ -136,6 +137,10 @@ public class JpaProperties {
|
|||
this.namingStrategy = namingStrategy;
|
||||
}
|
||||
|
||||
public void setNamingstrategy(Class<?> namingStrategy) {
|
||||
this.setNamingStrategy(namingStrategy);
|
||||
}
|
||||
|
||||
public String getDdlAuto() {
|
||||
return this.ddlAuto;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import static org.junit.Assert.assertThat;
|
|||
*
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTests {
|
||||
|
||||
|
@ -51,6 +52,21 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
|
|||
assertThat(actual, equalTo("org.hibernate.cfg.EJB3NamingStrategy"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamingStrategyThatWorkedInOneDotOhContinuesToWork() {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.jpa.hibernate.namingstrategy:"
|
||||
+ "org.hibernate.cfg.EJB3NamingStrategy");
|
||||
setupTestConfiguration();
|
||||
|
||||
this.context.refresh();
|
||||
LocalContainerEntityManagerFactoryBean bean = this.context
|
||||
.getBean(LocalContainerEntityManagerFactoryBean.class);
|
||||
String actual = (String) bean.getJpaPropertyMap().get(
|
||||
"hibernate.ejb.naming_strategy");
|
||||
assertThat(actual, equalTo("org.hibernate.cfg.EJB3NamingStrategy"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomNamingStrategyViaJpaProperties() throws Exception {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
|
|
Loading…
Reference in New Issue