Program: 65689
Project: 65689
Buggy source:
/** 
 * INTERNAL: Register a ReferenceResolver as an event listener on the session,  if one doesn't already exist.  Each source/target field will have a namespace resolver set as well. 
 * @see org.eclipse.persistence.internal.oxm.ReferenceResolver
 * @see org.eclipse.persistence.oxm.NamespaceResolver
 */
public void initialize(AbstractSession session) throws DescriptorException {
  if (null == referenceClass) {
    if (referenceClassName != null) {
      setReferenceClass(session.getDatasourcePlatform().getConversionManager().convertClassNameToClass(referenceClassName));
    }
  }
  if (!(null == referenceClass || referenceClass == ClassConstants.OBJECT)) {
    super.initialize(session);
  }
  ReferenceListener listener=new ReferenceListener();
  if (!(session.getEventManager().getListeners().contains(listener))) {
    session.getEventManager().addListener(listener);
  }
  XMLDescriptor descriptor=(XMLDescriptor)this.getDescriptor();
  XMLDescriptor targetDescriptor=(XMLDescriptor)getReferenceDescriptor();
  for (int index=0; index < sourceToTargetKeys.size(); index++) {
    XMLField sourceField=(XMLField)sourceToTargetKeys.get(index);
    XMLField targetField=(XMLField)sourceToTargetKeyFieldAssociations.remove(sourceField);
    sourceField=(XMLField)descriptor.buildField(sourceField);
    sourceToTargetKeys.set(index,sourceField);
    if (null != targetField) {
      if (null == targetDescriptor) {
        throw DescriptorException.referenceClassNotSpecified(this);
      }
      targetField=(XMLField)targetDescriptor.buildField(targetField);
    }
    sourceToTargetKeyFieldAssociations.put(sourceField,targetField);
  }
  if (this.inverseReferenceMapping != null) {
    if (null != this.inverseReferenceMapping.getAttributeAccessor()) {
      this.inverseReferenceMapping.getAttributeAccessor().initializeAttributes(this.referenceClass);
    }
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL: Register a ReferenceResolver as an event listener on the session,  if one doesn't already exist.  Each source/target field will have a namespace resolver set as well. 
 * @see org.eclipse.persistence.internal.oxm.ReferenceResolver
 * @see org.eclipse.persistence.oxm.NamespaceResolver
 */
public void initialize(AbstractSession session) throws DescriptorException {
  if (null == referenceClass) {
    if (referenceClassName != null) {
      setReferenceClass(session.getDatasourcePlatform().getConversionManager().convertClassNameToClass(referenceClassName));
    }
  }
  if (!(null == referenceClass || referenceClass == ClassConstants.OBJECT)) {
    super.initialize(session);
  }
  ReferenceListener listener=new ReferenceListener();
  if (!(session.getEventManager().getListeners().contains(listener))) {
    session.getEventManager().addListener(listener);
  }
  XMLDescriptor descriptor=(XMLDescriptor)this.getDescriptor();
  XMLDescriptor targetDescriptor=(XMLDescriptor)getReferenceDescriptor();
  for (int index=0; index < sourceToTargetKeys.size(); index++) {
    XMLField sourceField=(XMLField)sourceToTargetKeys.get(index);
    XMLField targetField=(XMLField)sourceToTargetKeyFieldAssociations.remove(sourceField);
    sourceField=(XMLField)descriptor.buildField(sourceField);
    sourceToTargetKeys.set(index,sourceField);
    if (null != targetField) {
      if (null == targetDescriptor) {
        throw DescriptorException.referenceClassNotSpecified(this);
      }
      List<DatabaseField> pkFields=targetDescriptor.getPrimaryKeyFields();
      for (int i=0; i < pkFields.size(); i++) {
        XMLField nextPKField=(XMLField)pkFields.get(i);
        if (targetField.equals(nextPKField)) {
          targetField=(XMLField)targetDescriptor.buildField(nextPKField);
          sourceField.setSchemaType(targetField.getSchemaType());
          break;
        }
      }
    }
    sourceToTargetKeyFieldAssociations.put(sourceField,targetField);
  }
  if (this.inverseReferenceMapping != null) {
    if (null != this.inverseReferenceMapping.getAttributeAccessor()) {
      this.inverseReferenceMapping.getAttributeAccessor().initializeAttributes(this.referenceClass);
    }
  }
}