From: erik Date: Sun, 4 Apr 2010 11:43:21 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.2~1^2~45 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=8ab4e7a87175b6fa1ea24721875143c5aa716273;p=utils --- diff --git a/support/test/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java b/support/test/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java new file mode 100644 index 00000000..5ba15e84 --- /dev/null +++ b/support/test/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java @@ -0,0 +1,30 @@ +package org.wamblee.support.persistence.toplink; + +import java.util.Map; + +import org.dbunit.dataset.filter.ITableFilterSimple; +import org.wamblee.support.persistence.JpaCustomizer; +import org.wamblee.support.persistence.PersistenceUnitDescription; + +public class ToplinkJpaCustomizer implements JpaCustomizer { + + public ToplinkJpaCustomizer() { + // Empty + } + + @Override + public void customize(PersistenceUnitDescription aPersistenceUnit, Map aJpaProperties) { + // Hack to make JNDI lookup of the datasource work with toplink + aJpaProperties.put("toplink.session.customizer", JndiSessionCustomizer.class + .getName()); + + // DDL generation for toplink + aJpaProperties.put("toplink.ddl-generation", "create-tables"); + } + + @Override + public ITableFilterSimple getJpaTables() { + return new ToplinkTables(); + } + +} diff --git a/support/test/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java b/support/test/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java new file mode 100644 index 00000000..cd3a0562 --- /dev/null +++ b/support/test/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java @@ -0,0 +1,20 @@ +package org.wamblee.support.persistence.toplink; + +import java.util.Arrays; +import java.util.List; + +import org.dbunit.dataset.DataSetException; +import org.dbunit.dataset.filter.ITableFilterSimple; + +/** + * Toplink-specific tables. + */ +public class ToplinkTables implements ITableFilterSimple { + + private static final List TABLES = Arrays.asList(new String[] { "SEQUENCE" } ); + + public boolean accept(String aTableName) throws DataSetException { + return TABLES.contains(aTableName); + } + +}