OPENJPA-1972 Update test and adapt to DB2 9.7 behavior changes.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1087429 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Albert Lee 2011-03-31 20:13:17 +00:00
parent 20b66ce0df
commit 03d4f2f8b6
2 changed files with 26 additions and 8 deletions
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql
openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr

View File

@ -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;
}
}

View File

@ -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 TestMixedLockManagerDeadlock extends SequencedActionsTest {
setUp(LockEmployee.class
, "openjpa.LockManager", "mixed"
);
expWriteLockExClasses = new HashMap<DBType,Class<?>[]>();
expWriteLockExClasses.put(DBType.db2, null);
expWriteLockExClasses.put(DBType.derby, ExpectingOptimisticLockExClass);
expWriteLockExClasses.put(DBType.oracle, null);
expWriteLockExClasses.put(DBType.sqlserver, ExpectingOptimisticLockExClass);
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, expDB2ExClass);
expWriteLockExClasses.put(DBType.derby, ExpectingOptimisticLockExClass);
expWriteLockExClasses.put(DBType.oracle, null);
expWriteLockExClasses.put(DBType.sqlserver, ExpectingOptimisticLockExClass);
}
/* ======== Find dead lock exception test ============*/