(no commit message)
authorErik Brakkee <erik@brakkee.org>
Sun, 4 Apr 2010 11:43:06 +0000 (11:43 +0000)
committerErik Brakkee <erik@brakkee.org>
Sun, 4 Apr 2010 11:43:06 +0000 (11:43 +0000)
support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java [new file with mode: 0644]
support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java [new file with mode: 0644]

diff --git a/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java b/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java
new file mode 100644 (file)
index 0000000..fa4def8
--- /dev/null
@@ -0,0 +1,31 @@
+package org.wamblee.support.persistence.hibernate;
+
+import java.util.Map;
+
+import org.dbunit.dataset.filter.ITableFilterSimple;
+import org.wamblee.support.persistence.JpaCustomizer;
+import org.wamblee.support.persistence.PersistenceUnitDescription;
+
+public class HibernateJpaCustomizer implements JpaCustomizer {
+
+    public HibernateJpaCustomizer() { 
+        // Empty
+    }
+    
+    @Override
+    public void customize(PersistenceUnitDescription aPersistenceUnit, Map<String, String> aJpaProperties) {
+        // Hibernate: Override transaction type and datasource
+        aJpaProperties.put("javax.persistence.transactionType", "RESOURCE_LOCAL");
+        aJpaProperties.put("javax.persistence.jtaDataSource", null);
+        aJpaProperties.put("javax.persistence.nonJtaDataSource", aPersistenceUnit.getJndiName());
+        
+        // Hibernate schema generation
+        aJpaProperties.put("hibernate.hbm2ddl.auto", "create");     
+    }
+    
+    @Override
+    public ITableFilterSimple getJpaTables() {
+        return new HibernateTables();
+    }
+
+}
diff --git a/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java b/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java
new file mode 100644 (file)
index 0000000..4b2c8a0
--- /dev/null
@@ -0,0 +1,20 @@
+package org.wamblee.support.persistence.hibernate;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.filter.ITableFilterSimple;
+
+/**
+ * Toplink-specific tables. 
+ */
+public class HibernateTables implements ITableFilterSimple {
+
+       private static final List<String> TABLES = Arrays.asList(new String[] { "" } );
+       
+       public boolean accept(String aTableName) throws DataSetException {
+               return TABLES.contains(aTableName);
+       }
+
+}