openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r1159899 - /openjpa/branches/2.0.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java
Date Sat, 20 Aug 2011 19:02:09 GMT
Author: mikedd
Date: Sat Aug 20 19:02:08 2011
New Revision: 1159899

URL: http://svn.apache.org/viewvc?rev=1159899&view=rev
Log:
Update TestNamedQueryLockMode to handle DB2 lock clauses

Modified:
    openjpa/branches/2.0.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java

Modified: openjpa/branches/2.0.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.0.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java?rev=1159899&r1=1159898&r2=1159899&view=diff
==============================================================================
--- openjpa/branches/2.0.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java
(original)
+++ openjpa/branches/2.0.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java
Sat Aug 20 19:02:08 2011
@@ -22,6 +22,7 @@ import javax.persistence.EntityManager;
 import javax.persistence.LockModeType;
 import javax.persistence.Query;
 
+import org.apache.openjpa.jdbc.sql.DB2Dictionary;
 import org.apache.openjpa.persistence.FetchPlan;
 import org.apache.openjpa.persistence.OpenJPAEntityManager;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
@@ -44,12 +45,12 @@ public class TestNamedQueryLockMode exte
             "openjpa.LockManager", "pessimistic", 
             "openjpa.Optimistic", "false"
             );
-        lockClause = getForUpdateClause();
     }
 
     public void testForUpdateClausePresentInNamedQueryWithLockMode() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
+        lockClause = getForUpdateClause();
         assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id",
0));
         em.getTransaction().rollback();
         em.getTransaction().begin();
@@ -75,15 +76,26 @@ public class TestNamedQueryLockMode exte
     public void testForUpdateClausePresentInQueryWithDefault() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
-        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));
-        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));        
+        lockClause = getForUpdateClause();
+		if (!DB2Dictionary.class.isAssignableFrom(getDBDictionary().getClass())) {
+			// Skip test because "for update" clause in DB2 depends on LockMode type (i.e. WITH RR/RS)
+			// plus dict.forUpdateClause is not sensitive to this implementation.  
+            assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));
+            assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));
+        }
+        
+        OpenJPAEntityManager oem = (OpenJPAEntityManager)em;
+        OpenJPAQuery<?> q = oem.createNamedQuery("findEmployeeById").setParameter("id",
0); 
+        FetchPlan fp = q.getFetchPlan();
+        fp.setReadLockMode(LockModeType.NONE);
+
         em.getTransaction().commit();
     }
     
     public void testForUpdateClauseAbsentInQueryWithFetchPlanNoneLockMode() {
         OpenJPAEntityManagerSPI em = emf.createEntityManager();
-        em.getTransaction().begin();
-        
+        em.getTransaction().begin();        
+        lockClause = getForUpdateClause();
         OpenJPAQuery<?> q = em.createNamedQuery("findEmployeeById").setParameter("id",
0); 
         FetchPlan fp = q.getFetchPlan();
         fp.setReadLockMode(LockModeType.NONE);
@@ -101,6 +113,7 @@ public class TestNamedQueryLockMode exte
     public void testForUpdateClauseAbsentInQueryWithExplictNoLock() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
+        lockClause = getForUpdateClause();
         assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithNoLock").setParameter("id",
0));
         assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithNoLock").setParameter("id",
0));
         em.getTransaction().commit();



Mime
View raw message