Program: 66792
Project: 66792
Buggy source:
public void testVersionChangeWithReadLock(){
  ServerSession session=JUnitTestCase.getServerSession();
  Assert.assertFalse("String_Node_Str",session.getPlatform().isSybase());
  if (!isJPA10() && isSelectForUpateNoWaitSupported()) {
    Employee employee=null;
    Integer version1;
    EntityManager em=createEntityManager();
    beginTransaction(em);
    try {
      employee=new Employee();
      employee.setFirstName("String_Node_Str");
      employee.setLastName("String_Node_Str");
      em.persist(employee);
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
      throw ex;
    }
    version1=employee.getVersion();
    try {
      beginTransaction(em);
      Query query=em.createQuery("String_Node_Str").setLockMode(LockModeType.PESSIMISTIC_READ);
      query.setHint(QueryHints.REFRESH,true);
      query.setHint(QueryHints.PESSIMISTIC_LOCK_TIMEOUT,0);
      query.setParameter("String_Node_Str",employee.getId());
      query.setParameter("String_Node_Str",employee.getFirstName());
      Employee queryResult=(Employee)query.getSingleResult();
      queryResult.setLastName("String_Node_Str");
      commitTransaction(em);
      assertTrue("String_Node_Str",version1.intValue() < employee.getVersion().intValue());
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
    }
  }
}

Fixed version (ground truth):
public void testVersionChangeWithReadLock(){
  ServerSession session=JUnitTestCase.getServerSession();
  if (!isJPA10() && isSelectForUpateNoWaitSupported()) {
    Employee employee=null;
    Integer version1;
    EntityManager em=createEntityManager();
    beginTransaction(em);
    try {
      employee=new Employee();
      employee.setFirstName("String_Node_Str");
      employee.setLastName("String_Node_Str");
      em.persist(employee);
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
      throw ex;
    }
    version1=employee.getVersion();
    try {
      beginTransaction(em);
      Query query=em.createQuery("String_Node_Str").setLockMode(LockModeType.PESSIMISTIC_READ);
      query.setHint(QueryHints.REFRESH,true);
      query.setHint(QueryHints.PESSIMISTIC_LOCK_TIMEOUT,0);
      query.setParameter("String_Node_Str",employee.getId());
      query.setParameter("String_Node_Str",employee.getFirstName());
      Employee queryResult=(Employee)query.getSingleResult();
      queryResult.setLastName("String_Node_Str");
      commitTransaction(em);
      assertTrue("String_Node_Str",version1.intValue() < employee.getVersion().intValue());
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
    }
  }
}