Program: 68513
Project: 68513
Buggy source:
/** 
 * Extract primary key attribute values from the domainObject.
 */
public Vector extractPrimaryKeyFromObject(Object domainObject,AbstractSession session,boolean shouldReturnNullIfNull){
  boolean isPersistenceEntity=domainObject instanceof PersistenceEntity;
  if (isPersistenceEntity) {
    Vector key=((PersistenceEntity)domainObject)._persistence_getPKVector();
    if (key != null) {
      return key;
    }
  }
  ClassDescriptor descriptor=this.descriptor;
  boolean isNull=false;
  if (descriptor.hasInheritance() && (domainObject.getClass() != descriptor.getJavaClass()) && (!domainObject.getClass().getSuperclass().equals(descriptor.getJavaClass()))) {
    return session.getDescriptor(domainObject).getObjectBuilder().extractPrimaryKeyFromObject(domainObject,session,shouldReturnNullIfNull);
  }
 else {
    List primaryKeyFields=descriptor.getPrimaryKeyFields();
    Vector primaryKeyValues=new NonSynchronizedVector(primaryKeyFields.size());
    List mappings=getPrimaryKeyMappings();
    int size=mappings.size();
    if (descriptor.hasSimplePrimaryKey()) {
      for (int index=0; index < size; index++) {
        AbstractDirectMapping mapping=(AbstractDirectMapping)mappings.get(index);
        Object keyValue=mapping.valueFromObject(domainObject,(DatabaseField)primaryKeyFields.get(index),session);
        if (keyValue == null || ((size == 1) && Helper.isEquivalentToNull(keyValue))) {
          if (shouldReturnNullIfNull) {
            return null;
          }
          isNull=true;
        }
        primaryKeyValues.add(keyValue);
      }
    }
 else {
      AbstractRecord databaseRow=createRecord(size);
      for (int index=0; index < size; index++) {
        DatabaseMapping mapping=(DatabaseMapping)mappings.get(index);
        if (mapping != null) {
          mapping.writeFromObjectIntoRow(domainObject,databaseRow,session);
        }
      }
      List primaryKeyClassifications=getPrimaryKeyClassifications();
      Platform platform=session.getPlatform(domainObject.getClass());
      for (int index=0; index < size; index++) {
        Class classification=(Class)primaryKeyClassifications.get(index);
        Object value=databaseRow.get((DatabaseField)primaryKeyFields.get(index));
        if (value == null || ((size == 1) && Helper.isEquivalentToNull(value))) {
          if (shouldReturnNullIfNull) {
            return null;
          }
          isNull=true;
        }
        primaryKeyValues.add(platform.convertObject(value,classification));
      }
    }
    if (isPersistenceEntity && (!isNull)) {
      ((PersistenceEntity)domainObject)._persistence_setPKVector(primaryKeyValues);
    }
    return primaryKeyValues;
  }
}

Fixed version (ground truth):
/** 
 * Extract primary key attribute values from the domainObject.
 */
public Vector extractPrimaryKeyFromObject(Object domainObject,AbstractSession session,boolean shouldReturnNullIfNull){
  boolean isPersistenceEntity=domainObject instanceof PersistenceEntity;
  if (isPersistenceEntity) {
    Vector key=((PersistenceEntity)domainObject)._persistence_getPKVector();
    if (key != null) {
      return key;
    }
  }
  ClassDescriptor descriptor=this.descriptor;
  boolean isNull=false;
  if (descriptor.hasInheritance() && (domainObject.getClass() != descriptor.getJavaClass()) && (!domainObject.getClass().getSuperclass().equals(descriptor.getJavaClass()))) {
    return session.getDescriptor(domainObject).getObjectBuilder().extractPrimaryKeyFromObject(domainObject,session,shouldReturnNullIfNull);
  }
 else {
    List primaryKeyFields=descriptor.getPrimaryKeyFields();
    Vector primaryKeyValues=new NonSynchronizedVector(primaryKeyFields.size());
    List mappings=getPrimaryKeyMappings();
    int size=mappings.size();
    if (descriptor.hasSimplePrimaryKey()) {
      for (int index=0; index < size; index++) {
        AbstractDirectMapping mapping=(AbstractDirectMapping)mappings.get(index);
        Object keyValue=mapping.valueFromObject(domainObject,(DatabaseField)primaryKeyFields.get(index),session);
        if (keyValue == null || ((size == 1) && Helper.isEquivalentToNull(keyValue))) {
          if (shouldReturnNullIfNull) {
            return null;
          }
          isNull=true;
        }
        primaryKeyValues.add(keyValue);
      }
    }
 else {
      AbstractRecord databaseRow=createRecord(size,session);
      for (int index=0; index < size; index++) {
        DatabaseMapping mapping=(DatabaseMapping)mappings.get(index);
        if (mapping != null) {
          mapping.writeFromObjectIntoRow(domainObject,databaseRow,session);
        }
      }
      List primaryKeyClassifications=getPrimaryKeyClassifications();
      Platform platform=session.getPlatform(domainObject.getClass());
      for (int index=0; index < size; index++) {
        Class classification=(Class)primaryKeyClassifications.get(index);
        Object value=databaseRow.get((DatabaseField)primaryKeyFields.get(index));
        if (value == null || ((size == 1) && Helper.isEquivalentToNull(value))) {
          if (shouldReturnNullIfNull) {
            return null;
          }
          isNull=true;
        }
        primaryKeyValues.add(platform.convertObject(value,classification));
      }
    }
    if (isPersistenceEntity && (!isNull)) {
      ((PersistenceEntity)domainObject)._persistence_setPKVector(primaryKeyValues);
    }
    return primaryKeyValues;
  }
}