Program: 66972
Project: 66972
Buggy source:
/** 
 * INTERNAL:
 * @param session typically will be a unit of work
 */
public void resolveReferences(AbstractSession session){
  for (int x=0, referencesSize=references.size(); x < referencesSize; x++) {
    Reference reference=(Reference)references.get(x);
    if (reference.getMapping() instanceof XMLCollectionReferenceMapping) {
      XMLCollectionReferenceMapping mapping=(XMLCollectionReferenceMapping)reference.getMapping();
      ContainerPolicy cPolicy=mapping.getContainerPolicy();
      Object container=cPolicy.containerInstance();
      createPKVectorsFromMap(reference);
      for (Iterator pkIt=reference.getPrimaryKeys().iterator(); pkIt.hasNext(); ) {
        Vector pkVector=(Vector)pkIt.next();
        Object value=session.getIdentityMapAccessor().getFromIdentityMap(pkVector,reference.getTargetClass());
        if (value != null) {
          cPolicy.addInto(value,container,session);
        }
      }
      mapping.setAttributeValueInObject(reference.getSourceObject(),container);
    }
 else     if (reference.getMapping() instanceof XMLObjectReferenceMapping) {
      Object value=session.getIdentityMapAccessor().getFromIdentityMap(reference.getPrimaryKeys(),reference.getTargetClass());
      if (value != null) {
        ((XMLObjectReferenceMapping)reference.getMapping()).setAttributeValueInObject(reference.getSourceObject(),value);
      }
      if (null != reference.getSetting()) {
        reference.getSetting().setValue(value);
      }
    }
  }
  if (session.isUnitOfWork()) {
    ((UnitOfWork)session).release();
  }
  references=new ArrayList();
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 * @param session typically will be a unit of work
 */
public void resolveReferences(AbstractSession session){
  for (int x=0, referencesSize=references.size(); x < referencesSize; x++) {
    Reference reference=(Reference)references.get(x);
    if (reference.getMapping() instanceof XMLCollectionReferenceMapping) {
      XMLCollectionReferenceMapping mapping=(XMLCollectionReferenceMapping)reference.getMapping();
      ContainerPolicy cPolicy=mapping.getContainerPolicy();
      Object container=null;
      if (mapping.getReuseContainer()) {
        Object currentObject=reference.getSourceObject();
        container=mapping.getAttributeAccessor().getAttributeValueFromObject(currentObject);
      }
 else {
        container=cPolicy.containerInstance();
      }
      createPKVectorsFromMap(reference);
      for (Iterator pkIt=reference.getPrimaryKeys().iterator(); pkIt.hasNext(); ) {
        Vector pkVector=(Vector)pkIt.next();
        Object value=session.getIdentityMapAccessor().getFromIdentityMap(pkVector,reference.getTargetClass());
        if (value != null) {
          cPolicy.addInto(value,container,session);
        }
      }
      mapping.setAttributeValueInObject(reference.getSourceObject(),container);
    }
 else     if (reference.getMapping() instanceof XMLObjectReferenceMapping) {
      Object value=session.getIdentityMapAccessor().getFromIdentityMap(reference.getPrimaryKeys(),reference.getTargetClass());
      if (value != null) {
        ((XMLObjectReferenceMapping)reference.getMapping()).setAttributeValueInObject(reference.getSourceObject(),value);
      }
      if (null != reference.getSetting()) {
        reference.getSetting().setValue(value);
      }
    }
  }
  if (session.isUnitOfWork()) {
    ((UnitOfWork)session).release();
  }
  references=new ArrayList();
}