Program: 66934
Project: 66934
Buggy source:
public void testMappedByIdExample1(){
  EntityManager em=createEntityManager();
  beginTransaction(em);
  Sargeant sargeant=new Sargeant();
  MasterCorporal masterCorporal=new MasterCorporal();
  MasterCorporalId masterCorporalId=new MasterCorporalId();
  try {
    sargeant.setName("String_Node_Str");
    em.persist(sargeant);
    masterCorporalId.setName("String_Node_Str");
    masterCorporal.setId(masterCorporalId);
    masterCorporal.setSargeant(sargeant);
    em.persist(masterCorporal);
    commitTransaction(em);
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
  em=createEntityManager();
  CriteriaBuilder qb=em.getCriteriaBuilder();
  CriteriaQuery<MasterCorporal> cq=qb.createQuery(MasterCorporal.class);
  Root<MasterCorporal> from=cq.from(MasterCorporal.class);
  cq.where(qb.and(qb.equal(from.get("String_Node_Str").get("String_Node_Str"),"String_Node_Str"),qb.equal(from.get("String_Node_Str").get("String_Node_Str"),sargeant.getSargeantId())));
  Query query1=em.createQuery(cq);
  MasterCorporal results1=(MasterCorporal)query1.getSingleResult();
  qb=em.getCriteriaBuilder();
  cq=qb.createQuery(MasterCorporal.class);
  from=cq.from(MasterCorporal.class);
  cq.where(qb.and(qb.equal(from.get("String_Node_Str").get("String_Node_Str"),"String_Node_Str"),qb.equal(from.get("String_Node_Str").get("String_Node_Str"),sargeant.getSargeantId())));
  Query query2=em.createQuery(cq);
  MasterCorporal results2=(MasterCorporal)query2.getSingleResult();
  MasterCorporal refreshedMasterCorporal=em.find(MasterCorporal.class,masterCorporalId);
  assertTrue("String_Node_Str",getServerSession().compareObjects(masterCorporal,refreshedMasterCorporal));
  assertTrue("String_Node_Str",refreshedMasterCorporal == results1);
  assertTrue("String_Node_Str",refreshedMasterCorporal == results2);
}

Fixed version (ground truth):
public void testMappedByIdExample1(){
  EntityManager em=createEntityManager();
  beginTransaction(em);
  Sargeant sargeant=new Sargeant();
  MasterCorporal masterCorporal=new MasterCorporal();
  MasterCorporalId masterCorporalId=new MasterCorporalId();
  try {
    sargeant.setName("String_Node_Str");
    em.persist(sargeant);
    masterCorporalId.setName("String_Node_Str");
    masterCorporal.setId(masterCorporalId);
    masterCorporal.setSargeant(sargeant);
    em.persist(masterCorporal);
    commitTransaction(em);
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
  em=createEntityManager();
  beginTransaction(em);
  try {
    CriteriaBuilder qb=em.getCriteriaBuilder();
    CriteriaQuery<MasterCorporal> cq=qb.createQuery(MasterCorporal.class);
    Root<MasterCorporal> from=cq.from(MasterCorporal.class);
    cq.where(qb.and(qb.equal(from.get("String_Node_Str").get("String_Node_Str"),"String_Node_Str"),qb.equal(from.get("String_Node_Str").get("String_Node_Str"),sargeant.getSargeantId())));
    Query query1=em.createQuery(cq);
    MasterCorporal results1=(MasterCorporal)query1.getSingleResult();
    qb=em.getCriteriaBuilder();
    cq=qb.createQuery(MasterCorporal.class);
    from=cq.from(MasterCorporal.class);
    cq.where(qb.and(qb.equal(from.get("String_Node_Str").get("String_Node_Str"),"String_Node_Str"),qb.equal(from.get("String_Node_Str").get("String_Node_Str"),sargeant.getSargeantId())));
    Query query2=em.createQuery(cq);
    MasterCorporal results2=(MasterCorporal)query2.getSingleResult();
    MasterCorporal refreshedMasterCorporal=em.find(MasterCorporal.class,masterCorporalId);
    assertTrue("String_Node_Str",getServerSession().compareObjects(masterCorporal,refreshedMasterCorporal));
    assertTrue("String_Node_Str",refreshedMasterCorporal == results1);
    assertTrue("String_Node_Str",refreshedMasterCorporal == results2);
  }
  finally {
    rollbackTransaction(em);
    closeEntityManager(em);
  }
}