Community
Participate
Working Groups
According to PessimisticLocking Test Plan http://aseng-wiki.us.oracle.com/asengwiki/display/ASQA/Pessimistic+Locking+Test+Plan, we need to add a list of new tests, these new tests and all existing tests together will have better coverage of scenarios exposed in JPA2.0 PessmisticLocking Functional Spec. The changes are: 1. add following two tests in EntityManagerJUnitTestSuite.java in advanced model testPESSIMISTIC_FORCE_INCREMENTLockOnNonVersionedEntity() testLockWithJoinedInheritanceStrategy() 2. add following four tests in AdvancedQueryTestSuite.java in jpql model testLockWithSecondaryTable testVersionChangeWithReadLock testVersionChangeWithWriteLock testNamedQueryAnnotationOverwritePersistenceXML 3. add a new namedquery in Employee.java in advanced model @NamedQuery( name="findAllEmployeesByIdAndFirstName", query="Select employee from Employee employee where employee.id = :id and employee.firstName = :firstName", hints={ @QueryHint(name=QueryHints.PESSIMISTIC_LOCK_TIMEOUT, value="15") } ) 4. add <property name="javax.persistence.lock.timeout" value="5"/> to persistence.xml under trunk\jpa\eclipselink.jpa.test\resource\eclipselink-annotation-model 5. add verification part in testQueryPESSIMISTIC_FORCE_INCREMENTLock in AdvancedQueryTestSuite.java in jpql model to implement the features as designed in testForceIncrementAsWriteLock, which is PESSIMISTIC_FORCE_INCREMENT lock can be used as PESSIMISTIC_WRITE lock //Verify if the entity has been updated correctly by using PESSIMISTIC_FORCE_INCREMENT as PESSIMISTIC_WRITE try { beginTransaction(em); Query query = em.createQuery("Select employee from Employee employee where employee.id = :id and employee.firstName = :firstName").setLockMode(LockModeType.PESSIMISTIC_FORCE_INCREMENT); query.setParameter("id", employee.getId()); query.setParameter("firstName", employee.getFirstName()); Employee queryResult = (Employee) query.getSingleResult(); rollbackTransaction(em); assertTrue("The last name is not updated by using PESSIMISTIC_FORCE_INCREMENT.", queryResult.getLastName().equals("Auger")); } catch (RuntimeException ex) { if (isTransactionActive(em)) { rollbackTransaction(em); } throw ex; } finally { closeEntityManager(em); }
6. change condition for running testPESSIMISTIC_FORCE_INCREMENTLock in EntityManagerJUnitTestSuite from "if (! isOnServer() && isSelectForUpateSupported())" to be "if (! isJPA10() && isSelectForUpateSupported())" 7. change condition for running test testQueryPESSIMISTIC_FORCE_INCREMENTLock in AdvancedQueryTestSuite.java from "if (! isOnServer() && isSelectForUpateSupported())" to be "if (! isJPA10() && isSelectForUpateSupported())"
Created attachment 151234 [details] patch for adding new tests to test JPA2.0 PessimisticLocking feature
checked in the patch in Main branch as revision 5731.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink