Fix test cases running in DB2 due to 1) dict.forUpdateClause must be obtained after emf is created because specific dictionary may override the value of this attribute, 2) The forUpdateClause in DB2 is LockMode type dependent, (i.e. WITH RR/RS) therefore can not depends on this attribute for positive test case comparison, negative test ok.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.1.x@1073539 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Albert Lee 2011-02-22 23:07:31 +00:00
parent 7eae35f88b
commit e5a5fef37a

View File

@ -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;
@ -76,8 +77,12 @@ public class TestNamedQueryLockMode extends SQLListenerTestCase {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
lockClause = getForUpdateClause();
assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
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);