You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by al...@apache.org on 2008/10/06 17:30:34 UTC

svn commit: r702177 - /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java

Author: allee8285
Date: Mon Oct  6 08:30:34 2008
New Revision: 702177

URL: http://svn.apache.org/viewvc?rev=702177&view=rev
Log:
Fix test case db preparation to allow test to repeat run without taking a duplicate key exception.

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java?rev=702177&r1=702176&r2=702177&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java Mon Oct  6 08:30:34 2008
@@ -291,6 +291,26 @@
                 Persistence.createEntityManagerFactory("test", props));
         
         EntityManagerImpl em = (EntityManagerImpl)emf.createEntityManager();
+
+        // Set/clean up tables for subsequent tests
+        em.getTransaction().begin();
+        for (int i = 0; i < 2; i++) {
+            TblParent p = em.find(TblParent.class, i);
+            if (p != null) {
+                Collection<TblChild> children = p.getTblChildren();
+                for (TblChild c : children) {
+                    Collection<TblGrandChild> gchildren = c
+                        .getTblGrandChildren();
+                    for (TblGrandChild gc : gchildren) {
+                        em.remove(gc);
+                    }
+                    em.remove(c);
+                }
+                em.remove(p);
+            }
+        }
+        em.getTransaction().commit();
+        em.clear();
         
         em.getTransaction().begin();
         for (int i = 0; i < 2; i++) {