Program: 64578
Project: 64578
Buggy source:
/** 
 * INTERNAL: Create (if necessary) and populate a reference object that will be used during the mapping reference resolution phase after unmarshalling is complete.
 * @param record
 * @param xmlField
 * @param object
 * @param session
 * @return
 */
public void buildReference(UnmarshalRecord record,XMLField xmlField,Object object,AbstractSession session){
  ReferenceResolver resolver=record.getReferenceResolver();
  if (resolver == null) {
    return;
  }
  Object srcObject=record.getCurrentObject();
  Reference reference=resolver.getReference(this,srcObject);
  CacheId primaryKeys;
  if (null == referenceClass || ClassConstants.OBJECT == referenceClass) {
    if (reference == null) {
      primaryKeys=new CacheId(new Object[1]);
      reference=new Reference(this,srcObject,referenceClass,primaryKeys);
      resolver.addReference(reference);
      record.reference(reference);
    }
 else {
      primaryKeys=(CacheId)reference.getPrimaryKey();
    }
    primaryKeys.set(0,object);
  }
 else {
    Vector pkFieldNames=referenceDescriptor.getPrimaryKeyFieldNames();
    if (reference == null) {
      primaryKeys=new CacheId(new Object[pkFieldNames.size()]);
      reference=new Reference(this,srcObject,referenceClass,primaryKeys);
      resolver.addReference(reference);
      record.reference(reference);
    }
 else {
      primaryKeys=(CacheId)reference.getPrimaryKey();
    }
    XMLField tgtFld=(XMLField)getSourceToTargetKeyFieldAssociations().get(xmlField);
    int idx=pkFieldNames.indexOf(tgtFld.getXPath());
    Object value=session.getDatasourcePlatform().getConversionManager().convertObject(object,referenceDescriptor.getTypedField(tgtFld).getType());
    if (value != null) {
      primaryKeys.set(idx,value);
    }
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL: Create (if necessary) and populate a reference object that will be used during the mapping reference resolution phase after unmarshalling is complete.
 * @param record
 * @param xmlField
 * @param object
 * @param session
 * @return
 */
public void buildReference(UnmarshalRecord record,XMLField xmlField,Object object,AbstractSession session){
  ReferenceResolver resolver=record.getReferenceResolver();
  if (resolver == null) {
    return;
  }
  Object srcObject=record.getCurrentObject();
  Reference reference=resolver.getReference(this,srcObject);
  CacheId primaryKeys;
  if (null == referenceClass || ClassConstants.OBJECT == referenceClass) {
    if (reference == null) {
      primaryKeys=new CacheId(new Object[1]);
      reference=new Reference(this,srcObject,referenceClass,primaryKeys);
      resolver.addReference(reference);
      record.reference(reference);
    }
 else {
      primaryKeys=(CacheId)reference.getPrimaryKey();
    }
    primaryKeys.set(0,object);
  }
 else {
    Vector pkFieldNames=referenceDescriptor.getPrimaryKeyFieldNames();
    if (reference == null) {
      primaryKeys=new CacheId(new Object[pkFieldNames.size()]);
      reference=new Reference(this,srcObject,referenceClass,primaryKeys);
      resolver.addReference(reference);
      record.reference(reference);
    }
 else {
      primaryKeys=(CacheId)reference.getPrimaryKey();
    }
    XMLField tgtFld=(XMLField)getSourceToTargetKeyFieldAssociations().get(xmlField);
    int idx=pkFieldNames.indexOf(tgtFld.getQualifiedName());
    Object value=session.getDatasourcePlatform().getConversionManager().convertObject(object,referenceDescriptor.getTypedField(tgtFld).getType());
    if (value != null) {
      primaryKeys.set(idx,value);
    }
  }
}