openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r702177 - /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/kernel/TestQuerySQLCache.java
Date Mon, 06 Oct 2008 15:30:34 GMT
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++) {



Mime
View raw message