Program: 49247
Project: 49247
Buggy source:
/** 
 * Removes the content references currently pointing to the specified content for the given owners. <p/></p> <strong>Note:</strong> product-content mappings are not modified by this method. <p/></p> <strong>Warning:</strong> Hibernate does not gracefully handle situations where the data backing an entity changes via direct SQL or other outside influence. While, logically, a refresh on the entity should resolve any divergence, in many cases it does not or causes errors. As such, whenever this method is called, any active Environment entities should be manually evicted from the session and re-queried to ensure they will not clobber the changes made by this method on persist, nor trigger any errors on refresh.
 * @param owner The owner for which to apply the reference changes
 * @param contentUuids A collection of content UUIDs representing the content entities to orphan
 */
@Transactional public void removeOwnerContentReferences(Owner owner,Collection<String> contentUuids){
  Session session=this.currentSession();
  Map<String,Object> criteria=new HashMap<String,Object>();
  criteria.put("String_Node_Str",owner.getId());
  criteria.put("String_Node_Str",contentUuids);
  int count=this.bulkSQLDelete(OwnerContent.DB_TABLE,criteria);
  log.info("String_Node_Str",count);
  String sql="String_Node_Str" + Environment.DB_TABLE + "String_Node_Str";
  List<String> ids=session.createSQLQuery(sql).setParameter("String_Node_Str",owner.getId()).list();
  if (ids != null && !ids.isEmpty()) {
    criteria.clear();
    criteria.put("String_Node_Str",ids);
    criteria.put("String_Node_Str",contentUuids);
    count=this.bulkSQLDelete(EnvironmentContent.DB_TABLE,criteria);
    log.info("String_Node_Str",count);
  }
 else {
    log.info("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Removes the content references currently pointing to the specified content for the given owners. <p/></p> <strong>Note:</strong> product-content mappings are not modified by this method. <p/></p> <strong>Warning:</strong> Hibernate does not gracefully handle situations where the data backing an entity changes via direct SQL or other outside influence. While, logically, a refresh on the entity should resolve any divergence, in many cases it does not or causes errors. As such, whenever this method is called, any active Environment entities should be manually evicted from the session and re-queried to ensure they will not clobber the changes made by this method on persist, nor trigger any errors on refresh.
 * @param owner The owner for which to apply the reference changes
 * @param contentUuids A collection of content UUIDs representing the content entities to orphan
 */
@Transactional public void removeOwnerContentReferences(Owner owner,Collection<String> contentUuids){
  if (contentUuids != null && !contentUuids.isEmpty()) {
    log.info("String_Node_Str",owner,contentUuids);
    Session session=this.currentSession();
    Map<String,Object> criteria=new HashMap<String,Object>();
    criteria.put("String_Node_Str",owner.getId());
    criteria.put("String_Node_Str",contentUuids);
    int count=this.bulkSQLDelete(OwnerContent.DB_TABLE,criteria);
    log.info("String_Node_Str",count);
    String sql="String_Node_Str" + Environment.DB_TABLE + "String_Node_Str";
    List<String> ids=session.createSQLQuery(sql).setParameter("String_Node_Str",owner.getId()).list();
    if (ids != null && !ids.isEmpty()) {
      criteria.clear();
      criteria.put("String_Node_Str",ids);
      criteria.put("String_Node_Str",contentUuids);
      count=this.bulkSQLDelete(EnvironmentContent.DB_TABLE,criteria);
      log.info("String_Node_Str",count);
    }
 else {
      log.info("String_Node_Str");
    }
  }
}