Program: 76
Project: 76
Buggy source:
/** 
 * @deprecated This is internal to XWikiHibernateStore and may be removed in the future.
 */
@Deprecated public void deleteXWikiCollection(BaseCollection object,XWikiContext context,boolean bTransaction,boolean evict) throws XWikiException {
  if (object == null) {
    return;
  }
  try {
    if (bTransaction) {
      checkHibernate(context);
      bTransaction=beginTransaction(context);
    }
    Session session=getSession(context);
    BaseClass bclass=object.getXClass(context);
    List<String> handledProps=new ArrayList<String>();
    if ((bclass != null) && (bclass.hasCustomMapping()) && context.getWiki().hasCustomMappings()) {
      handledProps=bclass.getCustomMappingPropertyList(context);
      Session dynamicSession=session.getSession(EntityMode.MAP);
      Object map=dynamicSession.get(bclass.getName(),Integer.valueOf(object.getId()));
      if (map != null) {
        if (evict) {
          dynamicSession.evict(map);
        }
        dynamicSession.delete(map);
      }
    }
    if (object.getXClassReference() != null) {
      for (      BaseElement property : (List<BaseElement>)object.getFieldList()) {
        if (!handledProps.contains(property.getName())) {
          if (evict) {
            session.evict(property);
          }
          if (session.get(property.getClass(),property) != null) {
            session.delete(property);
          }
        }
      }
    }
    if (!"String_Node_Str".equals(bclass.getCustomClass())) {
      BaseObject cobject=new BaseObject();
      cobject.setDocumentReference(object.getDocumentReference());
      cobject.setClassName(object.getClassName());
      cobject.setNumber(object.getNumber());
      if (object instanceof BaseObject) {
        cobject.setGuid(((BaseObject)object).getGuid());
      }
      cobject.setId(object.getId());
      if (evict) {
        session.evict(cobject);
      }
      session.delete(cobject);
    }
 else {
      if (evict) {
        session.evict(object);
      }
      session.delete(object);
    }
    if (bTransaction) {
      endTransaction(context,true);
    }
  }
 catch (  Exception e) {
    Object[] args={object.getName()};
    throw new XWikiException(XWikiException.MODULE_XWIKI_STORE,XWikiException.ERROR_XWIKI_STORE_HIBERNATE_DELETING_OBJECT,"String_Node_Str",e,args);
  }
 finally {
    try {
      if (bTransaction) {
        endTransaction(context,false);
      }
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
/** 
 * @deprecated This is internal to XWikiHibernateStore and may be removed in the future.
 */
@Deprecated public void deleteXWikiCollection(BaseCollection object,XWikiContext context,boolean bTransaction,boolean evict) throws XWikiException {
  if (object == null) {
    return;
  }
  try {
    if (bTransaction) {
      checkHibernate(context);
      bTransaction=beginTransaction(context);
    }
    Session session=getSession(context);
    BaseClass bclass=object.getXClass(context);
    List<String> handledProps=new ArrayList<String>();
    if ((bclass != null) && (bclass.hasCustomMapping()) && context.getWiki().hasCustomMappings()) {
      handledProps=bclass.getCustomMappingPropertyList(context);
      Session dynamicSession=session.getSession(EntityMode.MAP);
      Object map=dynamicSession.get(bclass.getName(),Integer.valueOf(object.getId()));
      if (map != null) {
        if (evict) {
          dynamicSession.evict(map);
        }
        dynamicSession.delete(map);
      }
    }
    if (object.getXClassReference() != null) {
      for (      BaseElement property : (Collection<BaseElement>)object.getFieldList()) {
        if (!handledProps.contains(property.getName())) {
          if (evict) {
            session.evict(property);
          }
          if (session.get(property.getClass(),property) != null) {
            session.delete(property);
          }
        }
      }
    }
    if (!"String_Node_Str".equals(bclass.getCustomClass())) {
      BaseObject cobject=new BaseObject();
      cobject.setDocumentReference(object.getDocumentReference());
      cobject.setClassName(object.getClassName());
      cobject.setNumber(object.getNumber());
      if (object instanceof BaseObject) {
        cobject.setGuid(((BaseObject)object).getGuid());
      }
      cobject.setId(object.getId());
      if (evict) {
        session.evict(cobject);
      }
      session.delete(cobject);
    }
 else {
      if (evict) {
        session.evict(object);
      }
      session.delete(object);
    }
    if (bTransaction) {
      endTransaction(context,true);
    }
  }
 catch (  Exception e) {
    Object[] args={object.getName()};
    throw new XWikiException(XWikiException.MODULE_XWIKI_STORE,XWikiException.ERROR_XWIKI_STORE_HIBERNATE_DELETING_OBJECT,"String_Node_Str",e,args);
  }
 finally {
    try {
      if (bTransaction) {
        endTransaction(context,false);
      }
    }
 catch (    Exception e) {
    }
  }
}