Program: 63319
Project: 63319
Buggy source:
/** 
 * Test that deleting an employee works correctly. This test case was added in 8177 for 324321 and modified for 325605. The issue is that the status enum will be cascade deleted even if it is not instantiated (lazy) because the owning object does not know if the collection is empty without instantiating it. DB2 will therefore emit warning logs that are printed at FINEST in this lazy case. This test is a modification of testDeleteEmployee() that verifies instantiated lists are also ok 11/17/2010-2.2 Michael O'Brien - 325605: Filter out SQL warnings that are not SQL statements but are logged at a non-warning level.  This affects only implementors of SessionLog that perform log diagnostics/tracking in addition to logging.
 */
public void testDeleteEmployee_with_status_enum_collection_instantiated(){
  Employee employee=new Employee();
  PhoneNumber homePhone=new PhoneNumber("String_Node_Str","String_Node_Str","String_Node_Str");
  PhoneNumber faxPhone=new PhoneNumber("String_Node_Str","String_Node_Str","String_Node_Str");
  employee.addPhoneNumber(homePhone);
  employee.addPhoneNumber(faxPhone);
  employee.addResponsibility("String_Node_Str");
  employee.addResponsibility("String_Node_Str");
  employee.addProject(new Project());
  employee.setWorkWeek(new HashSet<Employee.Weekdays>());
  employee.getWorkWeek().add(Employee.Weekdays.MONDAY);
  employee.getWorkWeek().add(Employee.Weekdays.TUESDAY);
  employee.setStatus(Employee.EmployeeStatus.PART_TIME);
  homePhone.addStatus(PhoneNumber.PhoneStatus.ASSIGNED);
  QuerySQLTracker counter=new QuerySQLTracker(getServerSession());
  EntityManager em=createEntityManager();
  try {
    beginTransaction(em);
    em.persist(employee);
    commitTransaction(em);
    closeEntityManager(em);
    clearCache();
    em=createEntityManager();
    beginTransaction(em);
    employee=em.find(Employee.class,employee.getId());
    employee.getPhoneNumbers();
    counter.getSqlStatements().clear();
    em.remove(employee);
    commitTransaction(em);
    if (isWeavingEnabled() && counter.getSqlStatements().size() > 13) {
      fail("String_Node_Str" + counter.getSqlStatements().size());
    }
    beginTransaction(em);
    verifyDelete(employee);
    commitTransaction(em);
  }
  finally {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    closeEntityManager(em);
  }
}

Fixed version (ground truth):
/** 
 * Test that deleting an employee works correctly. This test case was added in 8177 for 324321 and modified for 325605. The issue is that the status enum will be cascade deleted even if it is not instantiated (lazy) because the owning object does not know if the collection is empty without instantiating it. DB2 will therefore emit warning logs that are printed at FINEST in this lazy case. This test is a modification of testDeleteEmployee() that verifies instantiated lists are also ok 11/17/2010-2.2 Michael O'Brien - 325605: Filter out SQL warnings that are not SQL statements but are logged at a non-warning level.  This affects only implementors of SessionLog that perform log diagnostics/tracking in addition to logging.
 */
public void testDeleteEmployee_with_status_enum_collection_instantiated(){
  Employee employee=new Employee();
  PhoneNumber homePhone=new PhoneNumber("String_Node_Str","String_Node_Str","String_Node_Str");
  PhoneNumber faxPhone=new PhoneNumber("String_Node_Str","String_Node_Str","String_Node_Str");
  employee.addPhoneNumber(homePhone);
  employee.addPhoneNumber(faxPhone);
  employee.addResponsibility("String_Node_Str");
  employee.addResponsibility("String_Node_Str");
  employee.addProject(new Project());
  employee.setWorkWeek(new HashSet<Employee.Weekdays>());
  employee.getWorkWeek().add(Employee.Weekdays.MONDAY);
  employee.getWorkWeek().add(Employee.Weekdays.TUESDAY);
  employee.setStatus(Employee.EmployeeStatus.PART_TIME);
  homePhone.addStatus(PhoneNumber.PhoneStatus.ASSIGNED);
  QuerySQLTracker counter=new QuerySQLTracker(getServerSession());
  EntityManager em=createEntityManager();
  try {
    beginTransaction(em);
    em.persist(employee);
    commitTransaction(em);
    closeEntityManager(em);
    clearCache();
    em=createEntityManager();
    beginTransaction(em);
    employee=em.find(Employee.class,employee.getId());
    employee.getPhoneNumbers();
    counter.getSqlStatements().clear();
    em.remove(employee);
    commitTransaction(em);
    if (isWeavingEnabled() && counter.getSqlStatements().size() > 13) {
      fail("String_Node_Str" + counter.getSqlStatements().size());
    }
    beginTransaction(em);
    verifyDelete(employee);
    commitTransaction(em);
  }
  finally {
    if (isTransactionActive(em)) {
      rollbackTransaction(em);
    }
    if (counter != null) {
      counter.remove();
    }
    closeEntityManager(em);
  }
}