Program: 67409
Project: 67409
Buggy source:
/** 
 * INTERNAL: For an aggregate mapping the reference descriptor is cloned. The cloned descriptor is then assigned primary keys and table names before initialize. Once the cloned descriptor is initialized it is assigned as reference descriptor in the aggregate mapping. This is a very specific behavior for aggregate mappings. The original descriptor is used only for creating clones and after that the aggregate mapping never uses it. Some initialization is done in postInitialize to ensure the target descriptor's references are initialized.
 */
public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  ClassDescriptor clonedDescriptor=(ClassDescriptor)getReferenceDescriptor().clone();
  if (clonedDescriptor.isChildDescriptor()) {
    ClassDescriptor parentDescriptor=session.getDescriptor(clonedDescriptor.getInheritancePolicy().getParentClass());
    initializeParentInheritance(parentDescriptor,clonedDescriptor,session);
  }
  setReferenceDescriptor(clonedDescriptor);
  initializeReferenceDescriptor(clonedDescriptor);
  clonedDescriptor.preInitialize(session);
  clonedDescriptor.initialize(session);
  translateFields(clonedDescriptor,session);
  if (clonedDescriptor.hasInheritance() && clonedDescriptor.getInheritancePolicy().hasChildren()) {
    initializeChildInheritance(clonedDescriptor,session);
  }
  setFields(collectFields());
}

Fixed version (ground truth):
/** 
 * INTERNAL: For an aggregate mapping the reference descriptor is cloned. The cloned descriptor is then assigned primary keys and table names before initialize. Once the cloned descriptor is initialized it is assigned as reference descriptor in the aggregate mapping. This is a very specific behavior for aggregate mappings. The original descriptor is used only for creating clones and after that the aggregate mapping never uses it. Some initialization is done in postInitialize to ensure the target descriptor's references are initialized.
 */
public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  ClassDescriptor clonedDescriptor=(ClassDescriptor)getReferenceDescriptor().clone();
  if (clonedDescriptor.isChildDescriptor()) {
    ClassDescriptor parentDescriptor=session.getDescriptor(clonedDescriptor.getInheritancePolicy().getParentClass());
    initializeParentInheritance(parentDescriptor,clonedDescriptor,session);
  }
  setReferenceDescriptor(clonedDescriptor);
  for (  ManyToManyMapping overrideMapping : overrideManyToManyMappings) {
    DatabaseMapping mapping=clonedDescriptor.getMappingForAttributeName(overrideMapping.getAttributeName());
    if (mapping.isManyToManyMapping()) {
      ManyToManyMapping mappingClone=(ManyToManyMapping)mapping;
      mappingClone.setRelationTable(overrideMapping.getRelationTable());
      mappingClone.setSourceKeyFields(overrideMapping.getSourceKeyFields());
      mappingClone.setSourceRelationKeyFields(overrideMapping.getSourceRelationKeyFields());
      mappingClone.setTargetKeyFields(overrideMapping.getTargetKeyFields());
      mappingClone.setTargetRelationKeyFields(overrideMapping.getTargetRelationKeyFields());
    }
 else {
    }
  }
  for (  UnidirectionalOneToManyMapping overrideMapping : overrideUnidirectionalOneToManyMappings) {
    DatabaseMapping mapping=clonedDescriptor.getMappingForAttributeName(overrideMapping.getAttributeName());
    if (mapping.isUnidirectionalOneToManyMapping()) {
      UnidirectionalOneToManyMapping mappingClone=(UnidirectionalOneToManyMapping)mapping;
      mappingClone.setSourceKeyFields(overrideMapping.getSourceKeyFields());
      mappingClone.setTargetForeignKeyFields(overrideMapping.getTargetForeignKeyFields());
    }
 else {
    }
  }
  initializeReferenceDescriptor(clonedDescriptor);
  clonedDescriptor.preInitialize(session);
  clonedDescriptor.initialize(session);
  translateFields(clonedDescriptor,session);
  if (clonedDescriptor.hasInheritance() && clonedDescriptor.getInheritancePolicy().hasChildren()) {
    initializeChildInheritance(clonedDescriptor,session);
  }
  setFields(collectFields());
}