Permalink
Browse files

Use H2 Hibernate Dialect for testing

  • Loading branch information...
thomasdarimont committed Mar 4, 2012
1 parent 4d50f24 commit abac53392b0e064885a944603bba63a4afa37ba8
@@ -40,7 +40,7 @@
@Bean
public DataSource dataSource() {
- if (Arrays.asList(env.getActiveProfiles()).contains("testing")) {
+ if (isTestProfileActive()) {
// We use an embedded H2 database instance for testing
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).addScript("classpath:/db/schema.sql").build();
} else {
@@ -84,7 +84,15 @@ public HibernateJpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setShowSql(env.getProperty("persistence.hibernate.showSql", Boolean.class));
adapter.setGenerateDdl(env.getProperty("persistence.hibernate.generateDdl", Boolean.class));
- adapter.setDatabasePlatform(env.getProperty("persistence.hibernate.databasePlatform"));
+ if(isTestProfileActive()){
+ adapter.setDatabasePlatform("org.hibernate.dialect.H2Dialect");
+ }else{
+ adapter.setDatabasePlatform(env.getProperty("persistence.hibernate.databasePlatform"));
+ }
return adapter;
}
+
+ private boolean isTestProfileActive() {
+ return Arrays.asList(env.getActiveProfiles()).contains("testing");
+ }
}

0 comments on commit abac533

Please sign in to comment.