Program: 63341
Project: 63341
Buggy source:
/** 
 * Test the cascade removal of objects
 */
public void test12MWithCascadeFromOR(){
  EntityManager em=createEntityManager();
  try {
    beginTransaction(em);
    Vehicle vehicle=new Vehicle("String_Node_Str");
    Chassis chassis=new Chassis(1l);
    vehicle.setChassis(chassis);
    Wheel wheel1=new Wheel(1l);
    chassis.addWheel(wheel1);
    WheelNut wheelNut1=new WheelNut();
    WheelNut wheelNut2=new WheelNut();
    WheelNut wheelNut3=new WheelNut();
    WheelNut wheelNut4=new WheelNut();
    wheel1.addWheelNut(wheelNut1);
    wheel1.addWheelNut(wheelNut2);
    wheel1.addWheelNut(wheelNut3);
    wheel1.addWheelNut(wheelNut4);
    em.persist(vehicle);
    WheelNut wheelNut5=new WheelNut();
    WheelNut wheelNut6=new WheelNut();
    wheel1.removeWheelNut(wheelNut3);
    wheel1.removeWheelNut(wheelNut4);
    wheel1.addWheelNut(wheelNut5);
    wheel1.addWheelNut(wheelNut6);
    Wheel wheel2=new Wheel(2l);
    chassis.addWheel(wheel2);
    em.persist(vehicle);
    wheel2.addWheelNut(wheelNut3);
    wheel2.addWheelNut(wheelNut4);
    commitTransaction(em);
    closeEntityManager(em);
    clearCache();
    em=createEntityManager();
    beginTransaction(em);
    WheelNut wheelNut3Read=em.find(WheelNut.class,wheelNut3.getId());
    compareObjects(wheelNut3,wheelNut3Read);
    WheelNut wheelNut4Read=em.find(WheelNut.class,wheelNut4.getId());
    compareObjects(wheelNut4,wheelNut4Read);
    Wheel wheel1Read=em.find(Wheel.class,wheel1.getId());
    compareObjects(wheel1,wheel1);
    Wheel wheel2Read=em.find(Wheel.class,wheel2.getId());
    compareObjects(wheel2,wheel2);
    em.remove(em.find(Vehicle.class,vehicle.getId()));
    for (    WheelNut wheelNut : wheel1Read.getWheelNuts()) {
      em.remove(wheelNut);
    }
    for (    WheelNut wheelNut : wheel2Read.getWheelNuts()) {
      em.remove(wheelNut);
    }
    commitTransaction(em);
    closeEntityManager(em);
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * Test the cascade removal of objects
 */
public void test12MWithCascadeFromOR(){
  EntityManager em=createEntityManager();
  try {
    beginTransaction(em);
    Vehicle vehicle=new Vehicle("String_Node_Str");
    Chassis chassis=new Chassis(1l);
    vehicle.setChassis(chassis);
    Wheel wheel1=new Wheel(1l);
    wheel1.setTire(new Tire());
    chassis.addWheel(wheel1);
    WheelNut wheelNut1=new WheelNut();
    WheelNut wheelNut2=new WheelNut();
    WheelNut wheelNut3=new WheelNut();
    WheelNut wheelNut4=new WheelNut();
    wheel1.addWheelNut(wheelNut1);
    wheel1.addWheelNut(wheelNut2);
    wheel1.addWheelNut(wheelNut3);
    wheel1.addWheelNut(wheelNut4);
    em.persist(vehicle);
    WheelNut wheelNut5=new WheelNut();
    WheelNut wheelNut6=new WheelNut();
    wheel1.removeWheelNut(wheelNut3);
    wheel1.removeWheelNut(wheelNut4);
    wheel1.addWheelNut(wheelNut5);
    wheel1.addWheelNut(wheelNut6);
    Wheel wheel2=new Wheel(2l);
    wheel2.setTire(new Tire());
    chassis.addWheel(wheel2);
    em.persist(vehicle);
    wheel2.addWheelNut(wheelNut3);
    wheel2.addWheelNut(wheelNut4);
    commitTransaction(em);
    closeEntityManager(em);
    clearCache();
    em=createEntityManager();
    beginTransaction(em);
    WheelNut wheelNut3Read=em.find(WheelNut.class,wheelNut3.getId());
    compareObjects(wheelNut3,wheelNut3Read);
    WheelNut wheelNut4Read=em.find(WheelNut.class,wheelNut4.getId());
    compareObjects(wheelNut4,wheelNut4Read);
    Wheel wheel1Read=em.find(Wheel.class,wheel1.getId());
    compareObjects(wheel1,wheel1);
    Wheel wheel2Read=em.find(Wheel.class,wheel2.getId());
    compareObjects(wheel2,wheel2);
    em.remove(em.find(Vehicle.class,vehicle.getId()));
    for (    WheelNut wheelNut : wheel1Read.getWheelNuts()) {
      em.remove(wheelNut);
    }
    for (    WheelNut wheelNut : wheel2Read.getWheelNuts()) {
      em.remove(wheelNut);
    }
    commitTransaction(em);
    closeEntityManager(em);
  }
 catch (  RuntimeException e) {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
    throw e;
  }
}