From 49e8b0bd81de1bf5d9dab97a9747ecc2bf50e728 Mon Sep 17 00:00:00 2001 From: erik Date: Sun, 4 Apr 2010 11:43:06 +0000 Subject: [PATCH] --- .../hibernate/HibernateJpaCustomizer.java | 31 +++++++++++++++++++ .../hibernate/HibernateTables.java | 20 ++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 trunk/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java create mode 100644 trunk/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java diff --git a/trunk/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java b/trunk/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java new file mode 100644 index 00000000..fa4def8f --- /dev/null +++ b/trunk/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java @@ -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 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/trunk/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java b/trunk/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java new file mode 100644 index 00000000..4b2c8a09 --- /dev/null +++ b/trunk/support/test/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java @@ -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 TABLES = Arrays.asList(new String[] { "" } ); + + public boolean accept(String aTableName) throws DataSetException { + return TABLES.contains(aTableName); + } + +} -- 2.31.1