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
|
@ -28,8 +28,9 @@ 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")
|
||||
|
@ -99,7 +100,7 @@ public class JpaProperties {
|
|||
* Get configuration properties for the initialization of the main Hibernate
|
||||
* EntityManagerFactory. The result will always have ddl-auto=none, so that the schema
|
||||
* generation or validation can be deferred to a later stage.
|
||||
*
|
||||
*
|
||||
* @param dataSource the DataSource in case it is needed to determine the properties
|
||||
* @return some Hibernate properties for configuration
|
||||
*/
|
||||
|
@ -109,7 +110,7 @@ public class JpaProperties {
|
|||
|
||||
/**
|
||||
* Get the full configuration properties for the Hibernate EntityManagerFactory.
|
||||
*
|
||||
*
|
||||
* @param dataSource the DataSource in case it is needed to determine the properties
|
||||
* @return some Hibernate properties for configuration
|
||||
*/
|
||||
|
@ -136,6 +137,10 @@ public class JpaProperties {
|
|||
this.namingStrategy = namingStrategy;
|
||||
}
|
||||
|
||||
public void setNamingstrategy(Class<?> namingStrategy) {
|
||||
this.setNamingStrategy(namingStrategy);
|
||||
}
|
||||
|
||||
public String getDdlAuto() {
|
||||
return this.ddlAuto;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,10 @@ import static org.junit.Assert.assertThat;
|
|||
|
||||
/**
|
||||
* Tests for {@link HibernateJpaAutoConfiguration}.
|
||||
*
|
||||
*
|
||||
* @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