Ensure JPA vendor properties are period separated

If you bind to Map<String,Object> you get a nested Map instead
of period-separated keys. This change just makes JpaProperties
expose a Map<String,String> so the keys are sane.

Fixes gh-988
This commit is contained in:
Dave Syer
2014-05-30 10:23:14 +01:00
parent 2f653f0616
commit b0579c1cf3
7 changed files with 26 additions and 25 deletions

View File

@@ -139,7 +139,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
@Test
public void customJpaProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "spring.jpa.properties.a:b",
"spring.jpa.properties.c:d");
"spring.jpa.properties.a.b:c", "spring.jpa.properties.c:d");
setupTestConfiguration();
this.context.refresh();
LocalContainerEntityManagerFactoryBean bean = this.context
@@ -147,6 +147,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
Map<String, Object> map = bean.getJpaPropertyMap();
assertThat(map.get("a"), equalTo((Object) "b"));
assertThat(map.get("c"), equalTo((Object) "d"));
assertThat(map.get("a.b"), equalTo((Object) "c"));
}
@Test

View File

@@ -61,7 +61,7 @@ public class CustomHibernateJpaAutoConfigurationTests {
this.context.refresh();
JpaProperties bean = this.context.getBean(JpaProperties.class);
DataSource dataSource = this.context.getBean(DataSource.class);
String actual = (String) bean.getHibernateProperties(dataSource).get(
String actual = bean.getHibernateProperties(dataSource).get(
"hibernate.hbm2ddl.auto");
// Default is generic and safe
assertThat(actual, equalTo("none"));
@@ -78,7 +78,7 @@ public class CustomHibernateJpaAutoConfigurationTests {
this.context.refresh();
JpaProperties bean = this.context.getBean(JpaProperties.class);
DataSource dataSource = this.context.getBean(DataSource.class);
String actual = (String) bean.getHibernateProperties(dataSource).get(
String actual = bean.getHibernateProperties(dataSource).get(
"hibernate.hbm2ddl.auto");
assertThat(actual, equalTo("create-drop"));
}

View File

@@ -47,7 +47,7 @@ public class EntityManagerFactoryBuilderTests {
new HibernateJpaVendorAdapter(), this.properties, null);
LocalContainerEntityManagerFactoryBean result1 = factory
.dataSource(this.dataSource1)
.properties(Collections.singletonMap("foo", (Object) "spam")).build();
.properties(Collections.singletonMap("foo", "spam")).build();
assertFalse(result1.getJpaPropertyMap().isEmpty());
assertTrue(this.properties.getProperties().isEmpty());
}
@@ -58,7 +58,7 @@ public class EntityManagerFactoryBuilderTests {
new HibernateJpaVendorAdapter(), this.properties, null);
LocalContainerEntityManagerFactoryBean result1 = factory
.dataSource(this.dataSource1)
.properties(Collections.singletonMap("foo", (Object) "spam")).build();
.properties(Collections.singletonMap("foo", "spam")).build();
assertFalse(result1.getJpaPropertyMap().isEmpty());
LocalContainerEntityManagerFactoryBean result2 = factory.dataSource(
this.dataSource2).build();