nus-yam/ex-repair huggingface dataset:
Program: 66747
Project: 66747
Buggy source:
public static Test suite(){
  TestSuite suite=new TestSuite("String_Node_Str");
  suite.addTestSuite(JAXBBigDecimalStackTestCases.class);
  suite.addTestSuite(JAXBEmployeeArrayTestCases.class);
  suite.addTestSuite(JAXBEmployeeListTestCases.class);
  suite.addTestSuite(JAXBIntegerArrayTestCases.class);
  suite.addTestSuite(JAXBIntegerListTestCases.class);
  suite.addTestSuite(JAXBIntegerMyListTestCases.class);
  suite.addTestSuite(JAXBIntegerLinkedListTestCases.class);
  suite.addTestSuite(JAXBIntArrayTestCases.class);
  suite.addTestSuite(JAXBCharArrayTestCases.class);
  suite.addTestSuite(JAXBBooleanArrayTestCases.class);
  suite.addTestSuite(JAXBListNameCollisionEmployeeTestCases.class);
  suite.addTestSuite(JAXBListNameCollisionEmployee2TestCases.class);
  suite.addTestSuite(JAXBEmployeesAndIntegersTestCases.class);
  suite.addTestSuite(JAXBStringIntegerHashMapTestCases.class);
  suite.addTestSuite(JAXBStringEmployeeMapTestCases.class);
  suite.addTestSuite(JAXBStringEmployeeHashtableTestCases.class);
  suite.addTestSuite(JAXBListOfObjectsNonRootTestCases.class);
  suite.addTestSuite(JAXBObjectCollectionsTestCases.class);
  suite.addTestSuite(JAXBMultipleMapsTestCases.class);
  suite.addTestSuite(JAXBMultipleMapsNamespaceTestCases.class);
  suite.addTestSuite(JAXBTypedListTestCases.class);
  return suite;
}

Fixed version (ground truth):
public static Test suite(){
  TestSuite suite=new TestSuite("String_Node_Str");
  suite.addTestSuite(JAXBBigDecimalStackTestCases.class);
  suite.addTestSuite(JAXBEmployeeArrayTestCases.class);
  suite.addTestSuite(JAXBEmployeeListTestCases.class);
  suite.addTestSuite(JAXBIntegerArrayTestCases.class);
  suite.addTestSuite(JAXBIntegerListTestCases.class);
  suite.addTestSuite(JAXBIntegerMyListTestCases.class);
  suite.addTestSuite(JAXBIntegerLinkedListTestCases.class);
  suite.addTestSuite(JAXBIntArrayTestCases.class);
  suite.addTestSuite(JAXBIntListTestCases.class);
  suite.addTestSuite(JAXBCharArrayTestCases.class);
  suite.addTestSuite(JAXBBooleanArrayTestCases.class);
  suite.addTestSuite(JAXBListNameCollisionEmployeeTestCases.class);
  suite.addTestSuite(JAXBListNameCollisionEmployee2TestCases.class);
  suite.addTestSuite(JAXBEmployeesAndIntegersTestCases.class);
  suite.addTestSuite(JAXBStringIntegerHashMapTestCases.class);
  suite.addTestSuite(JAXBStringEmployeeMapTestCases.class);
  suite.addTestSuite(JAXBStringEmployeeHashtableTestCases.class);
  suite.addTestSuite(JAXBListOfObjectsNonRootTestCases.class);
  suite.addTestSuite(JAXBObjectCollectionsTestCases.class);
  suite.addTestSuite(JAXBMultipleMapsTestCases.class);
  suite.addTestSuite(JAXBMultipleMapsNamespaceTestCases.class);
  suite.addTestSuite(JAXBTypedListTestCases.class);
  return suite;
}
Program: 66748
Project: 66748
Buggy source:
public void testcreateNativeQueryWithSelectSQL() throws Exception {
  EntityManager em=createEntityManager();
  try {
    beginTransaction(em);
    Query query1=em.createNativeQuery("String_Node_Str");
    Query query2=em.createNativeQuery("String_Node_Str");
    Query query3=em.createNativeQuery("String_Node_Str");
    Collection c1=query1.getResultList();
    assertTrue("String_Node_Str",c1 != null);
    int result=0;
    try {
      result=query1.executeUpdate();
    }
 catch (    RuntimeException ex) {
      rollbackTransaction(em);
      beginTransaction(em);
    }
    query2.executeUpdate();
    Collection c2=query1.getResultList();
    assertTrue("String_Node_Str",c2 != null);
    query3.executeUpdate();
    Collection c3=query1.getResultList();
    assertTrue("String_Node_Str",c3 != null);
    assertTrue("String_Node_Str" + result + "String_Node_Str",result == 0);
    assertTrue("String_Node_Str",c2.size() == (c1.size() + 1));
    assertTrue("String_Node_Str",c3.size() == c1.size());
  }
  finally {
    try {
      rollbackTransaction(em);
      closeEntityManager(em);
    }
 catch (    Exception ee) {
    }
  }
}

Fixed version (ground truth):
public void testcreateNativeQueryWithSelectSQL() throws Exception {
  EntityManager em=createEntityManager();
  try {
    beginTransaction(em);
    Query query1=em.createNativeQuery("String_Node_Str");
    Collection c1=query1.getResultList();
    assertTrue("String_Node_Str",c1 != null);
    int result=0;
    try {
      result=query1.executeUpdate();
    }
 catch (    RuntimeException ex) {
      rollbackTransaction(em);
      closeEntityManager(em);
      em=createEntityManager();
      beginTransaction(em);
      query1=em.createNativeQuery("String_Node_Str");
    }
    Query query2=em.createNativeQuery("String_Node_Str");
    Query query3=em.createNativeQuery("String_Node_Str");
    query2.executeUpdate();
    Collection c2=query1.getResultList();
    assertTrue("String_Node_Str",c2 != null);
    query3.executeUpdate();
    Collection c3=query1.getResultList();
    assertTrue("String_Node_Str",c3 != null);
    assertTrue("String_Node_Str" + result + "String_Node_Str",result == 0);
    assertTrue("String_Node_Str",c2.size() == (c1.size() + 1));
    assertTrue("String_Node_Str",c3.size() == c1.size());
  }
  finally {
    try {
      rollbackTransaction(em);
      closeEntityManager(em);
    }
 catch (    Exception ee) {
    }
  }
}
Program: 66749
Project: 66749
Buggy source:
public QName getXmlTagName(){
  return this.xmlTagName;
}

Fixed version (ground truth):
/** 
 * Root element name associated with this type;
 */
public QName getXmlTagName(){
  return this.xmlTagName;
}
Program: 66750
Project: 66750
Buggy source:
public Type getType(){
  return this.type;
}

Fixed version (ground truth):
/** 
 * The type to be bound.
 */
public Type getType(){
  return this.type;
}
Program: 66751
Project: 66751
Buggy source:
public ElementScope getElementScope(){
  return this.elementScope;
}

Fixed version (ground truth):
/** 
 * Indicates if a global element should be generated for this type.
 */
public ElementScope getElementScope(){
  return this.elementScope;
}
Program: 66752
Project: 66752
Buggy source:
public Annotation[] getAnnotations(){
  return this.annotations;
}

Fixed version (ground truth):
/** 
 * Representing parameter level annotations that should be applied to this  type.
 */
public Annotation[] getAnnotations(){
  return this.annotations;
}
Program: 66755
Project: 66755
Buggy source:
public void postAcquireConnection(SessionEvent event){
  Connection conn=((DatabaseAccessor)event.getResult()).getConnection();
  Statement stmt1=null;
  Statement stmt2=null;
  ResultSet result=null;
  int isolationLevel;
  try {
    stmt1=conn.createStatement();
    result=stmt1.executeQuery("String_Node_Str");
    result.next();
    isolationLevel=result.getInt(1);
    if (isolationLevel > 0) {
      stmt2=conn.createStatement();
      stmt2.execute("String_Node_Str");
      stmt2.close();
      connections.put(conn,isolationLevel);
    }
  }
 catch (  SQLException sqlException) {
    throw new TestProblemException("String_Node_Str",sqlException);
  }
 finally {
    if (result != null) {
      try {
        result.close();
      }
 catch (      SQLException ex) {
      }
    }
    if (stmt1 != null) {
      try {
        stmt1.close();
      }
 catch (      SQLException ex) {
      }
    }
    if (stmt2 != null) {
      try {
        stmt2.close();
      }
 catch (      SQLException ex) {
      }
    }
  }
}

Fixed version (ground truth):
public void postAcquireConnection(SessionEvent event){
  Connection conn=((DatabaseAccessor)event.getResult()).getConnection();
  Statement stmt1=null;
  Statement stmt2=null;
  ResultSet result=null;
  Integer isolationLevel;
  try {
    stmt1=conn.createStatement();
    result=stmt1.executeQuery("String_Node_Str");
    result.next();
    isolationLevel=new Integer(result.getInt(1));
    if (isolationLevel > 0) {
      stmt2=conn.createStatement();
      stmt2.execute("String_Node_Str");
      stmt2.close();
      connections.put(conn,isolationLevel);
    }
  }
 catch (  SQLException sqlException) {
    throw new TestProblemException("String_Node_Str",sqlException);
  }
 finally {
    if (result != null) {
      try {
        result.close();
      }
 catch (      SQLException ex) {
      }
    }
    if (stmt1 != null) {
      try {
        stmt1.close();
      }
 catch (      SQLException ex) {
      }
    }
    if (stmt2 != null) {
      try {
        stmt2.close();
      }
 catch (      SQLException ex) {
      }
    }
  }
}
Program: 66756
Project: 66756
Buggy source:
public void preReleaseConnection(SessionEvent event){
  Connection conn=((DatabaseAccessor)event.getResult()).getConnection();
  Statement stmt=null;
  try {
    int isolationLevel=connections.remove(conn);
    stmt=conn.createStatement();
    stmt.execute("String_Node_Str" + isolationLevel);
    stmt.close();
  }
 catch (  SQLException sqlException) {
    throw new TestProblemException("String_Node_Str",sqlException);
  }
 finally {
    if (stmt != null) {
      try {
        stmt.close();
      }
 catch (      SQLException ex) {
      }
    }
  }
}

Fixed version (ground truth):
public void preReleaseConnection(SessionEvent event){
  Connection conn=((DatabaseAccessor)event.getResult()).getConnection();
  Statement stmt=null;
  try {
    Integer isolationLevel=connections.remove(conn);
    if (isolationLevel != null) {
      stmt=conn.createStatement();
      stmt.execute("String_Node_Str" + isolationLevel);
      stmt.close();
    }
  }
 catch (  SQLException sqlException) {
    throw new TestProblemException("String_Node_Str",sqlException);
  }
 finally {
    if (stmt != null) {
      try {
        stmt.close();
      }
 catch (      SQLException ex) {
      }
    }
  }
}
Program: 66757
Project: 66757
Buggy source:
public void testMerge(){
  EntityManager em=createEntityManager();
  beginTransaction(em);
  try {
    Image image=new Image();
    image.setId(5001);
    SerializableNonEntity sne=new SerializableNonEntity();
    sne.setSomeValue(1l);
    image.setCustomAttribute1(sne);
    em.persist(image);
    commitTransaction(em);
    closeEntityManager(em);
    image.getCustomAttribute1().setSomeValue(2l);
    em=createEntityManager();
    beginTransaction(em);
    em.merge(image);
    commitTransaction(em);
    em.clear();
    clearCache();
    image=em.find(Image.class,5001);
    assertTrue("String_Node_Str",image.getCustomAttribute1().getSomeValue() == 2l);
    beginTransaction(em);
    em.remove(image);
    commitTransaction(em);
    clearCache();
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
  closeEntityManager(em);
}

Fixed version (ground truth):
public void testMerge(){
  EntityManager em=createEntityManager();
  beginTransaction(em);
  try {
    Image image=new Image();
    image.setId(5001);
    SerializableNonEntity sne=new SerializableNonEntity();
    sne.setSomeValue(1l);
    image.setCustomAttribute1(sne);
    em.persist(image);
    commitTransaction(em);
    closeEntityManager(em);
    image.getCustomAttribute1().setSomeValue(2l);
    em=createEntityManager();
    beginTransaction(em);
    em.merge(image);
    commitTransaction(em);
    em.clear();
    clearCache();
    beginTransaction(em);
    image=em.find(Image.class,5001);
    assertTrue("String_Node_Str",image.getCustomAttribute1().getSomeValue() == 2l);
    em.remove(image);
    commitTransaction(em);
    clearCache();
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
  closeEntityManager(em);
}
Program: 66760
Project: 66760
Buggy source:
/** 
 * Load a dynamic project from deployment XML creating dynamic types for all descriptors where the provided class name does not exist.
 * @param resourceStream
 * @param login
 * @param dynamicClassLoader
 * @return a Project with {@link DynamicClassLoader} and associated{@link DynamicClassWriter} configured. Ensure if a newLogin/Platform is being configured that the {@link ConversionManager#getLoader()} is maintained.<p> <tt>null</tt> is returned if the resourcePath cannot locate a deployment XML
 * @throws IOException
 */
public static Project loadDynamicProject(InputStream resourceStream,DatabaseLogin login,DynamicClassLoader dynamicClassLoader) throws IOException {
  if (resourceStream == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (dynamicClassLoader == null) {
    throw new NullPointerException("String_Node_Str");
  }
  ObjectPersistenceWorkbenchXMLProject opmProject=new ObjectPersistenceWorkbenchXMLProject();
  Document document=xmlParser.parse(resourceStream);
  Project project=XMLProjectReader.readObjectPersistenceRuntimeFormat(document,dynamicClassLoader,opmProject);
  if (project != null) {
    if (login == null) {
      if (project.getLogin() == null) {
        project.setLogin(new DatabaseLogin());
      }
    }
 else {
      project.setLogin(login);
    }
    if (project.getLogin().getPlatform() == null) {
      project.getLogin().setPlatform(new DatabasePlatform());
    }
    project.getLogin().getPlatform().getConversionManager().setLoader(dynamicClassLoader);
    for (Iterator<?> i=project.getAliasDescriptors().values().iterator(); i.hasNext(); ) {
      ClassDescriptor descriptor=(ClassDescriptor)i.next();
      if (descriptor.getJavaClass() == null) {
        createType(dynamicClassLoader,descriptor,project);
      }
    }
    project.convertClassNamesToClasses(dynamicClassLoader);
  }
  return project;
}

Fixed version (ground truth):
public static Project loadDynamicProject(Project project,DatabaseLogin login,DynamicClassLoader dynamicClassLoader){
  if (project != null) {
    if (login == null) {
      if (project.getLogin() == null) {
        project.setLogin(new DatabaseLogin());
      }
    }
 else {
      project.setLogin(login);
    }
    if (project.getLogin().getPlatform() == null) {
      project.getLogin().setPlatform(new DatabasePlatform());
    }
    project.getLogin().getPlatform().getConversionManager().setLoader(dynamicClassLoader);
    for (Iterator<?> i=project.getAliasDescriptors().values().iterator(); i.hasNext(); ) {
      ClassDescriptor descriptor=(ClassDescriptor)i.next();
      if (descriptor.getJavaClass() == null) {
        createType(dynamicClassLoader,descriptor,project);
      }
    }
    project.convertClassNamesToClasses(dynamicClassLoader);
  }
  return project;
}
Program: 66768
Project: 66768
Buggy source:
public static Test suite(){
  TestSuite suite=new TestSuite();
  suite.setName("String_Node_Str");
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  return suite;
}

Fixed version (ground truth):
public static Test suite(){
  TestSuite suite=new TestSuite();
  suite.setName("String_Node_Str");
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  return suite;
}
Program: 66769
Project: 66769
Buggy source:
/** 
 * Return if pessimistic locking/select for update nowait is supported for this test platform. Currently testing supports nowait on Oracle, SQLServer. PostgreSQL also supports NOWAIT, but doesn't support the outer joins used in the tests.
 */
public boolean isSelectForUpateNoWaitSupported(){
  DatabasePlatform platform=getServerSession().getPlatform();
  if (!(platform.isOracle() || platform.isSQLServer())) {
    warning("String_Node_Str");
    return false;
  }
  return true;
}

Fixed version (ground truth):
public boolean isSelectForUpateNoWaitSupported(String puName){
  DatabasePlatform platform=getServerSession(puName).getPlatform();
  if (!(platform.isOracle() || platform.isSQLServer())) {
    warning("String_Node_Str");
    return false;
  }
  return true;
}
Program: 66770
Project: 66770
Buggy source:
/** 
 * Return if pessimistic locking/select for update is supported for this test platform. Currently testing supports select for update on Oracle, MySQL, SQLServer, TimesTen. Some of the other platforms may have some support for select for update, but the databases we test with for these do not have sufficient support to pass the tests. TODO: Need to recheck tests on DB2 as it has some support for this. Derby has some support, but does not work with joins (2008-12-01).
 */
public boolean isSelectForUpateSupported(){
  DatabasePlatform platform=getServerSession().getPlatform();
  if (platform.isFirebird() || platform.isH2() || platform.isHSQL()|| platform.isAccess()|| platform.isSybase()|| platform.isSQLAnywhere()|| platform.isDerby()|| platform.isPostgreSQL()) {
    warning("String_Node_Str");
    return false;
  }
  return true;
}

Fixed version (ground truth):
public boolean isSelectForUpateSupported(String puName){
  DatabasePlatform platform=getServerSession(puName).getPlatform();
  if (platform.isFirebird() || platform.isH2() || platform.isHSQL()|| platform.isAccess()|| platform.isSybase()|| platform.isSQLAnywhere()|| platform.isDerby()|| platform.isPostgreSQL()) {
    warning("String_Node_Str");
    return false;
  }
  return true;
}
Program: 66771
Project: 66771
Buggy source:
/** 
 * Return if stored procedures are supported for the database platform for the test database.
 */
public boolean supportsStoredProcedures(){
  DatabasePlatform platform=getServerSession().getPlatform();
  if (platform.isOracle() || platform.isSybase() || platform.isMySQL()|| platform.isSQLServer()) {
    return true;
  }
  warning("String_Node_Str");
  return false;
}

Fixed version (ground truth):
public boolean supportsStoredProcedures(String puName){
  DatabasePlatform platform=getServerSession(puName).getPlatform();
  if (platform.isOracle() || platform.isSybase() || platform.isMySQL()|| platform.isSQLServer()) {
    return true;
  }
  warning("String_Node_Str");
  return false;
}
Program: 66772
Project: 66772
Buggy source:
/** 
 * Tests a named-stored-procedure-query setting
 */
public void testNamedStoredProcedureQuery(){
  EntityManager em=createEntityManager(m_persistenceUnit);
  beginTransaction(em);
  try {
    Address address1=new Address();
    address1.setCity("String_Node_Str");
    address1.setPostalCode("String_Node_Str");
    address1.setProvince("String_Node_Str");
    address1.setStreet("String_Node_Str");
    address1.setCountry("String_Node_Str");
    em.persist(address1);
    commitTransaction(em);
    Address address2=(Address)em.createNamedQuery("String_Node_Str").setParameter("String_Node_Str",address1.getId()).getSingleResult();
    assertTrue("String_Node_Str",address2.equals(address1));
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
  closeEntityManager(em);
}

Fixed version (ground truth):
/** 
 * Tests a named-stored-procedure-query setting
 */
public void testNamedStoredProcedureQuery(){
  if (!supportsStoredProcedures(m_persistenceUnit)) {
    return;
  }
  EntityManager em=createEntityManager(m_persistenceUnit);
  beginTransaction(em);
  try {
    Address address1=new Address();
    address1.setCity("String_Node_Str");
    address1.setPostalCode("String_Node_Str");
    address1.setProvince("String_Node_Str");
    address1.setStreet("String_Node_Str");
    address1.setCountry("String_Node_Str");
    em.persist(address1);
    commitTransaction(em);
    Address address2=(Address)em.createNamedQuery("String_Node_Str").setParameter("String_Node_Str",address1.getId()).getSingleResult();
    assertTrue("String_Node_Str",address2.equals(address1));
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
  closeEntityManager(em);
}
Program: 66773
Project: 66773
Buggy source:
/** 
 * Tests a named-stored-procedure-query setting
 */
public void testNamedStoredProcedureQueryInOut(){
  EntityManager em=createEntityManager(m_persistenceUnit);
  beginTransaction(em);
  try {
    Address address1=new Address();
    address1.setCity("String_Node_Str");
    address1.setPostalCode("String_Node_Str");
    address1.setProvince("String_Node_Str");
    address1.setStreet("String_Node_Str");
    address1.setCountry("String_Node_Str");
    em.persist(address1);
    commitTransaction(em);
    Address address2=(Address)em.createNamedQuery("String_Node_Str").setParameter("String_Node_Str",address1.getId()).getSingleResult();
    assertTrue("String_Node_Str",(address1.getId() == address2.getId()) && (address1.getStreet().equals(address2.getStreet())));
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
  closeEntityManager(em);
}

Fixed version (ground truth):
/** 
 * Tests a named-stored-procedure-query setting
 */
public void testNamedStoredProcedureQueryInOut(){
  if (!supportsStoredProcedures(m_persistenceUnit)) {
    return;
  }
  EntityManager em=createEntityManager(m_persistenceUnit);
  beginTransaction(em);
  try {
    Address address1=new Address();
    address1.setCity("String_Node_Str");
    address1.setPostalCode("String_Node_Str");
    address1.setProvince("String_Node_Str");
    address1.setStreet("String_Node_Str");
    address1.setCountry("String_Node_Str");
    em.persist(address1);
    commitTransaction(em);
    Address address2=(Address)em.createNamedQuery("String_Node_Str").setParameter("String_Node_Str",address1.getId()).getSingleResult();
    assertTrue("String_Node_Str",(address1.getId() == address2.getId()) && (address1.getStreet().equals(address2.getStreet())));
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
  closeEntityManager(em);
}
Program: 66775
Project: 66775
Buggy source:
/** 
 * Convenience method for determining if an element already exists in a given sequence.  If an element exists whose name is equal to 'elementName' true is returned.  False otherwise.
 * @param elementName
 * @param seq
 * @return
 */
protected Element elementExistsInSequence(String elementName,String refString,Sequence seq){
  if (seq.isEmpty()) {
    return null;
  }
  List<Element> existingElements=seq.getOrderedElements();
  for (  Element element : existingElements) {
    if ((element.getRef() != null && element.getRef().equals(refString)) || (element.getName() != null && element.getName().equals(elementName))) {
      return element;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Convenience method for determining if an element already exists in a given sequence.  If an element exists whose name is equal to 'elementName' true is returned.  False otherwise.
 * @param elementName
 * @param seq
 * @return
 */
protected Element elementExistsInSequence(String elementName,String refString,Sequence seq){
  if (seq.isEmpty()) {
    return null;
  }
  List existingElements=seq.getOrderedElements();
  if (existingElements != null) {
    Iterator elementIt=existingElements.iterator();
    while (elementIt.hasNext()) {
      Element element;
      try {
        element=(Element)elementIt.next();
      }
 catch (      ClassCastException cce) {
        continue;
      }
      if ((element.getRef() != null && element.getRef().equals(refString)) || (element.getName() != null && element.getName().equals(elementName))) {
        return element;
      }
    }
  }
  return null;
}
Program: 66776
Project: 66776
Buggy source:
/** 
 * Return the schema type as a string for a given QName and Schema.  The schema's  namespace resolver will be used to determine the prefix (if any) to use. 
 * @param schemaType
 * @param workingSchema
 * @return
 */
protected String getSchemaTypeString(QName schemaType,Schema workingSchema){
  String schemaTypeString=schemaType.getLocalPart();
  String uri=schemaType.getNamespaceURI();
  String prefix=workingSchema.getNamespaceResolver().resolveNamespaceURI(uri);
  if (prefix == null && !areNamespacesEqual(uri,workingSchema.getDefaultNamespace())) {
    if (uri.equals(XMLConstants.SCHEMA_URL)) {
      prefix=workingSchema.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_PREFIX);
    }
 else     if (uri.equals(XMLConstants.SCHEMA_INSTANCE_URL)) {
      prefix=workingSchema.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
    }
 else {
      prefix=workingSchema.getNamespaceResolver().generatePrefix();
    }
    workingSchema.getNamespaceResolver().put(prefix,uri);
  }
  if (prefix != null) {
    schemaTypeString=prefix + XMLConstants.COLON + schemaTypeString;
  }
  return schemaTypeString;
}

Fixed version (ground truth):
/** 
 * Return the schema type as a string for a given QName and Schema.  The schema's  namespace resolver will be used to determine the prefix (if any) to use. 
 * @param schemaType
 * @param workingSchema
 * @return
 */
protected String getSchemaTypeString(QName schemaType,Schema workingSchema){
  String schemaTypeString=schemaType.getLocalPart();
  String uri=schemaType.getNamespaceURI();
  String prefix=workingSchema.getNamespaceResolver().resolveNamespaceURI(uri);
  if (prefix == null && !areNamespacesEqual(uri,workingSchema.getDefaultNamespace())) {
    if (uri.equals(XMLConstants.SCHEMA_URL)) {
      prefix=workingSchema.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_PREFIX);
    }
 else     if (uri.equals(XMLConstants.SCHEMA_INSTANCE_URL)) {
      prefix=workingSchema.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
    }
 else     if (uri.equals(XMLConstants.REF_URL)) {
      prefix=workingSchema.getNamespaceResolver().generatePrefix(XMLConstants.REF_PREFIX);
    }
 else {
      prefix=workingSchema.getNamespaceResolver().generatePrefix();
    }
    workingSchema.getNamespaceResolver().put(prefix,uri);
  }
  if (prefix != null) {
    schemaTypeString=prefix + XMLConstants.COLON + schemaTypeString;
  }
  return schemaTypeString;
}
Program: 66777
Project: 66777
Buggy source:
/** 
 * Default constructor.
 */
public AggregateObjectMapping(){
  aggregateToSourceFieldNames=new HashMap(5);
  overrideManyToManyMappings=new ArrayList<ManyToManyMapping>();
  overrideUnidirectionalOneToManyMappings=new ArrayList<UnidirectionalOneToManyMapping>();
  isNullAllowed=true;
}

Fixed version (ground truth):
/** 
 * Default constructor.
 */
public AggregateObjectMapping(){
  aggregateToSourceFieldNames=new HashMap(5);
  mapsIdMappings=new ArrayList<DatabaseMapping>();
  overrideManyToManyMappings=new ArrayList<ManyToManyMapping>();
  overrideUnidirectionalOneToManyMappings=new ArrayList<UnidirectionalOneToManyMapping>();
  isNullAllowed=true;
}
Program: 66779
Project: 66779
Buggy source:
public CompositePKTableCreator(){
  setName("String_Node_Str");
  addTableDefinition(buildADMIN_CONTRACTTable());
  addTableDefinition(buildADMINTable());
  addTableDefinition(buildSCIENTISTTable());
  addTableDefinition(buildDEPARTMENTTable());
  addTableDefinition(buildDEPT_ADMINTable());
  addTableDefinition(buildCUBICLETable());
  addTableDefinition(buildSARGEANTTable());
  addTableDefinition(buildMASTERCORPORALTable());
  addTableDefinition(buildMAJORTable());
  addTableDefinition(buildMAJORGENERALTable());
  addTableDefinition(buildCAPTAINTable());
  addTableDefinition(buildBRIGADIERGENERALTable());
  addTableDefinition(buildCORPORALTable());
  addTableDefinition(buildPRIVATETable());
  addTableDefinition(buildGENERALTable());
  addTableDefinition(buildLIEUTENANTGENERALTable());
  addTableDefinition(buildLIEUTENANTTable());
  addTableDefinition(buildSECONDLIEUTENANTTable());
  addTableDefinition(buildOFFICERCADETTable());
  addTableDefinition(buildLACKEYTable());
  addTableDefinition(buildLACKEYCREWTable());
  addTableDefinition(buildOFFICETable());
  addTableDefinition(buildBOOKIETable());
  addTableDefinition(buildCELLNUMBERTable());
  addTableDefinition(buildADMINPOOLTable());
}

Fixed version (ground truth):
public CompositePKTableCreator(){
  setName("String_Node_Str");
  addTableDefinition(buildADMIN_CONTRACTTable());
  addTableDefinition(buildADMINTable());
  addTableDefinition(buildSCIENTISTTable());
  addTableDefinition(buildDEPARTMENTTable());
  addTableDefinition(buildDEPT_ADMINTable());
  addTableDefinition(buildCUBICLETable());
  addTableDefinition(buildSARGEANTTable());
  addTableDefinition(buildMASTERCORPORALTable());
  addTableDefinition(buildMASTERCORPORALCLONETable());
  addTableDefinition(buildMAJORTable());
  addTableDefinition(buildMAJORGENERALTable());
  addTableDefinition(buildCAPTAINTable());
  addTableDefinition(buildBRIGADIERGENERALTable());
  addTableDefinition(buildCORPORALTable());
  addTableDefinition(buildPRIVATETable());
  addTableDefinition(buildGENERALTable());
  addTableDefinition(buildLIEUTENANTGENERALTable());
  addTableDefinition(buildLIEUTENANTTable());
  addTableDefinition(buildSECONDLIEUTENANTTable());
  addTableDefinition(buildOFFICERCADETTable());
  addTableDefinition(buildLACKEYTable());
  addTableDefinition(buildLACKEYCREWTable());
  addTableDefinition(buildOFFICETable());
  addTableDefinition(buildBOOKIETable());
  addTableDefinition(buildCELLNUMBERTable());
  addTableDefinition(buildADMINPOOLTable());
}
Program: 66780
Project: 66780
Buggy source:
public static Test suite(){
  TestSuite suite=new TestSuite();
  suite.setName("String_Node_Str");
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  return suite;
}

Fixed version (ground truth):
public static Test suite(){
  TestSuite suite=new TestSuite();
  suite.setName("String_Node_Str");
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  suite.addTest(new AdvancedCompositePKJunitTest("String_Node_Str"));
  return suite;
}
Program: 66781
Project: 66781
Buggy source:
public boolean isSelectForUpateSupported(String puName){
  DatabasePlatform platform=getServerSession(puName).getPlatform();
  if (platform.isFirebird() || platform.isH2() || platform.isHSQL()|| platform.isAccess()|| platform.isSybase()|| platform.isSQLAnywhere()|| platform.isDerby()|| platform.isPostgreSQL()) {
    warning("String_Node_Str");
    return false;
  }
  return true;
}

Fixed version (ground truth):
public boolean isSelectForUpateSupported(String puName){
  DatabasePlatform platform=getServerSession(puName).getPlatform();
  if (platform.isFirebird() || platform.isH2() || platform.isHSQL()|| platform.isAccess()|| platform.isSQLAnywhere()|| platform.isDerby()|| platform.isPostgreSQL()) {
    warning("String_Node_Str");
    return false;
  }
  return true;
}
Program: 66784
Project: 66784
Buggy source:
public void testPESSIMISTIC_READLockWithNoChanges(){
  ServerSession session=JUnitTestCase.getServerSession();
  Assert.assertFalse("String_Node_Str",session.getPlatform().isSybase());
  if (!isOnServer() && isSelectForUpateSupported()) {
    Employee employee=null;
    Integer version1;
    EntityManager em=createEntityManager();
    try {
      beginTransaction(em);
      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);
      employee=em.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_READ);
      commitTransaction(em);
      assertTrue("String_Node_Str",version1.intValue() == employee.getVersion().intValue());
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
  }
}

Fixed version (ground truth):
public void testPESSIMISTIC_READLockWithNoChanges(){
  ServerSession session=JUnitTestCase.getServerSession();
  if (!isOnServer() && isSelectForUpateSupported()) {
    Employee employee=null;
    Integer version1;
    EntityManager em=createEntityManager();
    try {
      beginTransaction(em);
      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);
      employee=em.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_READ);
      commitTransaction(em);
      assertTrue("String_Node_Str",version1.intValue() == employee.getVersion().intValue());
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
  }
}
Program: 66785
Project: 66785
Buggy source:
public void testPESSIMISTIC_FORCE_INCREMENTLock(){
  ServerSession session=JUnitTestCase.getServerSession();
  Assert.assertFalse("String_Node_Str",session.getPlatform().isSybase());
  if (!isJPA10() && isSelectForUpateSupported()) {
    Employee employee=null;
    Integer version1;
    EntityManager em=createEntityManager();
    try {
      beginTransaction(em);
      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);
      employee=em.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_FORCE_INCREMENT);
      commitTransaction(em);
      assertTrue("String_Node_Str",version1.intValue() < employee.getVersion().intValue());
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
  }
}

Fixed version (ground truth):
public void testPESSIMISTIC_FORCE_INCREMENTLock(){
  ServerSession session=JUnitTestCase.getServerSession();
  if (!isJPA10() && isSelectForUpateSupported()) {
    Employee employee=null;
    Integer version1;
    EntityManager em=createEntityManager();
    try {
      beginTransaction(em);
      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);
      employee=em.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_FORCE_INCREMENT);
      commitTransaction(em);
      assertTrue("String_Node_Str",version1.intValue() < employee.getVersion().intValue());
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
  }
}
Program: 66788
Project: 66788
Buggy source:
public void testPESSIMISTIC_WRITELockWithNoChanges(){
  ServerSession session=JUnitTestCase.getServerSession();
  Assert.assertFalse("String_Node_Str",session.getPlatform().isSybase());
  if (!isOnServer() && isSelectForUpateSupported()) {
    Employee employee=null;
    Integer version1;
    EntityManager em=createEntityManager();
    try {
      beginTransaction(em);
      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);
      employee=em.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_WRITE);
      commitTransaction(em);
      assertTrue("String_Node_Str",version1.intValue() == employee.getVersion().intValue());
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
  }
}

Fixed version (ground truth):
public void testPESSIMISTIC_WRITELockWithNoChanges(){
  ServerSession session=JUnitTestCase.getServerSession();
  if (!isOnServer() && isSelectForUpateSupported()) {
    Employee employee=null;
    Integer version1;
    EntityManager em=createEntityManager();
    try {
      beginTransaction(em);
      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);
      employee=em.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_WRITE);
      commitTransaction(em);
      assertTrue("String_Node_Str",version1.intValue() == employee.getVersion().intValue());
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
  }
}
Program: 66791
Project: 66791
Buggy source:
public void testPESSIMISTIC_FORCE_INCREMENTLockOnNonVersionedEntity(){
  ServerSession session=JUnitTestCase.getServerSession();
  Assert.assertFalse("String_Node_Str",session.getPlatform().isSybase());
  if (!isJPA10()) {
    Department dept=null;
    EntityManager em=createEntityManager();
    try {
      beginTransaction(em);
      dept=new Department();
      em.persist(dept);
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
      throw ex;
    }
    try {
      beginTransaction(em);
      dept=em.find(Department.class,dept.getId(),LockModeType.PESSIMISTIC_FORCE_INCREMENT);
      rollbackTransaction(em);
      fail("String_Node_Str");
    }
 catch (    PersistenceException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
    }
 finally {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
    }
  }
}

Fixed version (ground truth):
public void testPESSIMISTIC_FORCE_INCREMENTLockOnNonVersionedEntity(){
  ServerSession session=JUnitTestCase.getServerSession();
  if (!isJPA10()) {
    Department dept=null;
    EntityManager em=createEntityManager();
    try {
      beginTransaction(em);
      dept=new Department();
      em.persist(dept);
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
      throw ex;
    }
    try {
      beginTransaction(em);
      dept=em.find(Department.class,dept.getId(),LockModeType.PESSIMISTIC_FORCE_INCREMENT);
      rollbackTransaction(em);
      fail("String_Node_Str");
    }
 catch (    PersistenceException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
    }
 finally {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
    }
  }
}
Program: 66794
Project: 66794
Buggy source:
public void testLockWithSecondaryTable(){
  ServerSession session=JUnitTestCase.getServerSession();
  Assert.assertFalse("String_Node_Str",session.getPlatform().isSybase());
  if (!isOnServer() && isSelectForUpateSupported()) {
    EntityManager em=createEntityManager();
    Exception pessimisticLockException=null;
    try {
      beginTransaction(em);
      List employees=em.createQuery("String_Node_Str").setLockMode(LockModeType.PESSIMISTIC_WRITE).getResultList();
      Employee employee=(Employee)employees.get(0);
      employee.setSalary(90000);
      EntityManager em2=createEntityManager();
      try {
        beginTransaction(em2);
        Employee employee2=em2.find(Employee.class,employee.getId());
        HashMap properties=new HashMap();
        properties.put(QueryHints.PESSIMISTIC_LOCK_TIMEOUT,0);
        em2.lock(employee2,LockModeType.PESSIMISTIC_WRITE,properties);
        employee2.setSalary(100000);
        commitTransaction(em2);
      }
 catch (      PersistenceException ex) {
        if (ex instanceof javax.persistence.PessimisticLockException) {
          pessimisticLockException=ex;
        }
 else {
          throw ex;
        }
      }
 finally {
        closeEntityManager(em2);
      }
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
    assertFalse("String_Node_Str",pessimisticLockException == null);
  }
}

Fixed version (ground truth):
public void testLockWithSecondaryTable(){
  ServerSession session=JUnitTestCase.getServerSession();
  if (!isOnServer() && isSelectForUpateSupported()) {
    EntityManager em=createEntityManager();
    Exception pessimisticLockException=null;
    try {
      beginTransaction(em);
      List employees=em.createQuery("String_Node_Str").setLockMode(LockModeType.PESSIMISTIC_WRITE).getResultList();
      Employee employee=(Employee)employees.get(0);
      employee.setSalary(90000);
      EntityManager em2=createEntityManager();
      try {
        beginTransaction(em2);
        Employee employee2=em2.find(Employee.class,employee.getId());
        HashMap properties=new HashMap();
        properties.put(QueryHints.PESSIMISTIC_LOCK_TIMEOUT,0);
        em2.lock(employee2,LockModeType.PESSIMISTIC_WRITE,properties);
        employee2.setSalary(100000);
        commitTransaction(em2);
      }
 catch (      PersistenceException ex) {
        if (ex instanceof javax.persistence.PessimisticLockException) {
          pessimisticLockException=ex;
        }
 else {
          throw ex;
        }
      }
 finally {
        closeEntityManager(em2);
      }
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
    assertFalse("String_Node_Str",pessimisticLockException == null);
  }
}