openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r1087429 - in /openjpa: branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/ trunk/openjpa-jdbc/src/main/java/org/apache/open...
Date Thu, 31 Mar 2011 20:13:18 GMT
Author: allee8285
Date: Thu Mar 31 20:13:17 2011
New Revision: 1087429

URL: http://svn.apache.org/viewvc?rev=1087429&view=rev
Log:
OPENJPA-1972 Update test and adapt to DB2 9.7 behavior changes.

Modified:
    openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java

Modified: openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=1087429&r1=1087428&r2=1087429&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Thu Mar 31 20:13:17 2011
@@ -209,7 +209,7 @@ public class DB2Dictionary
 
         // ... and finish the cast
         if (toCast) {
-            Class c = ((Lit) val).getType();
+            Class<?> c = ((Lit) val).getType();
             int javaTypeCode = JavaTypes.getTypeCode(c);
             int jdbcTypeCode = getJDBCType(javaTypeCode, false);
             String typeName = getTypeName(jdbcTypeCode);
@@ -689,7 +689,7 @@ public class DB2Dictionary
     private void appendXmlComparison1(SQLBuffer buf, String op, 
             FilterValue lhs, FilterValue rhs) {
         boolean castrhs = false;
-        Class rc = Filters.wrap(rhs.getType());
+        Class<?> rc = Filters.wrap(rhs.getType());
         int type = 0;
         if (rhs.isConstant()) {
             type = getJDBCType(JavaTypes.getTypeCode(rc), false);
@@ -1118,4 +1118,12 @@ public class DB2Dictionary
         }
         super.setDate(stmnt, idx, val, col);
     }
+
+    public int getDB2MajorVersion() {
+        return maj;
+    }
+
+    public int getDB2MinorVersion() {
+        return min;
+    }
 }

Modified: openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java?rev=1087429&r1=1087428&r2=1087429&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java
(original)
+++ openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java
Thu Mar 31 20:13:17 2011
@@ -24,6 +24,9 @@ import java.util.HashMap;
 import javax.persistence.EntityManager;
 import javax.persistence.LockModeType;
 
+import org.apache.openjpa.jdbc.sql.DB2Dictionary;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+
 /**
  * Test EntityManager find/namedQuery deadlock exceptions.
  */
@@ -44,15 +47,22 @@ public class TestMixedLockManagerDeadloc
         setUp(LockEmployee.class
             , "openjpa.LockManager", "mixed"
         );
+        commonSetUp();
+        EntityManager em = emf.createEntityManager();
+        dbType = getDBType(em);
+
+        DBDictionary dict = getDBDictionary();
+		Class<?>[] expDB2ExClass = ExpectingOptimisticLockExClass;
+		if (DB2Dictionary.class.isAssignableFrom(dict.getClass())) {
+			DB2Dictionary db2dict = (DB2Dictionary) dict;
+			if ((db2dict.getDB2MajorVersion() * 100 + db2dict.getDB2MinorVersion()) > 905)
+				expDB2ExClass = null;
+		}
         expWriteLockExClasses = new HashMap<DBType,Class<?>[]>();
-        expWriteLockExClasses.put(DBType.db2, null);
+        expWriteLockExClasses.put(DBType.db2, expDB2ExClass);
         expWriteLockExClasses.put(DBType.derby, ExpectingOptimisticLockExClass);
         expWriteLockExClasses.put(DBType.oracle, null);
         expWriteLockExClasses.put(DBType.sqlserver, ExpectingOptimisticLockExClass);
-
-        commonSetUp();
-        EntityManager em = emf.createEntityManager();
-        dbType = getDBType(em);
     }
 
     /* ======== Find dead lock exception test ============*/

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=1087429&r1=1087428&r2=1087429&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Thu Mar 31 20:13:17 2011
@@ -209,7 +209,7 @@ public class DB2Dictionary
 
         // ... and finish the cast
         if (toCast) {
-            Class c = ((Lit) val).getType();
+            Class<?> c = ((Lit) val).getType();
             int javaTypeCode = JavaTypes.getTypeCode(c);
             int jdbcTypeCode = getJDBCType(javaTypeCode, false);
             String typeName = getTypeName(jdbcTypeCode);
@@ -677,7 +677,7 @@ public class DB2Dictionary
     private void appendXmlComparison1(SQLBuffer buf, String op, 
             FilterValue lhs, FilterValue rhs) {
         boolean castrhs = false;
-        Class rc = Filters.wrap(rhs.getType());
+        Class<?> rc = Filters.wrap(rhs.getType());
         int type = 0;
         if (rhs.isConstant()) {
             type = getJDBCType(JavaTypes.getTypeCode(rc), false);
@@ -1107,4 +1107,12 @@ public class DB2Dictionary
         }
         super.setDate(stmnt, idx, val, col);
     }
+
+    public int getDB2MajorVersion() {
+        return maj;
+    }
+
+    public int getDB2MinorVersion() {
+        return min;
+    }
 }

Modified: openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java?rev=1087429&r1=1087428&r2=1087429&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java
(original)
+++ openjpa/trunk/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerDeadlock.java
Thu Mar 31 20:13:17 2011
@@ -24,6 +24,9 @@ import java.util.HashMap;
 import javax.persistence.EntityManager;
 import javax.persistence.LockModeType;
 
+import org.apache.openjpa.jdbc.sql.DB2Dictionary;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+
 /**
  * Test EntityManager find/namedQuery deadlock exceptions.
  */
@@ -44,15 +47,22 @@ public class TestMixedLockManagerDeadloc
         setUp(LockEmployee.class
             , "openjpa.LockManager", "mixed"
         );
+        commonSetUp();
+        EntityManager em = emf.createEntityManager();
+        dbType = getDBType(em);
+
+        DBDictionary dict = getDBDictionary();
+		Class<?>[] expDB2ExClass = ExpectingOptimisticLockExClass;
+		if (DB2Dictionary.class.isAssignableFrom(dict.getClass())) {
+			DB2Dictionary db2dict = (DB2Dictionary) dict;
+			if ((db2dict.getDB2MajorVersion() * 100 + db2dict.getDB2MinorVersion()) > 905)
+				expDB2ExClass = null;
+		}
         expWriteLockExClasses = new HashMap<DBType,Class<?>[]>();
-        expWriteLockExClasses.put(DBType.db2, null);
+        expWriteLockExClasses.put(DBType.db2, expDB2ExClass);
         expWriteLockExClasses.put(DBType.derby, ExpectingOptimisticLockExClass);
         expWriteLockExClasses.put(DBType.oracle, null);
         expWriteLockExClasses.put(DBType.sqlserver, ExpectingOptimisticLockExClass);
-
-        commonSetUp();
-        EntityManager em = emf.createEntityManager();
-        dbType = getDBType(em);
     }
 
     /* ======== Find dead lock exception test ============*/



Mime
View raw message