Program: 64132
Project: 64132
Buggy source:
/** 
 * INTERNAL: So, here's the deal ... this method typically gets called when defaulting  pk's name, primary table names etc. for various mappings. The problem  however is that we go beyond the spec and allow more mappings to be  specified on embeddable classes. For example, a M-M would default its  join table and join columns using the info from its owning descriptor.  The problem then is ... what to do when this embedabble has multiple  owning descriptors? That is, is shared. Right now, their pk names from  the owners better be same or mappings must be fully specified and not use  any defaults. I think that is somewhat ok given we're going beyond the  spec and TopLink doesn't even support it anyway??? So the stance is, we'll allow the extra mappings on embeddables that are  not shared, however on shared cases there are restrictions. Users should  use mapped superclasses when they have a need to share complex  embeddables. Or they can write customizers to modify their embeddable descriptors  after initialize (after they have been cloned) Future: the metadata processing 'could' set all necessary (per owning  descriptor) metadata and have the descriptor initialize code handle it. Metadata processing would process embeddable classes as it currently does  for MappedSuperclasses. Clone them and process under each owning entity  context. At descriptor initialize time, we would avoid cloning the  aggregate descriptor and use the one metadata processing provided.  Investigate further at a later date ... Callers to this method are ... BasicCollectionAccessor - processCollectionTable - defaults pk names from the owning descriptor. RelationshipAccessor - processJoinTable - defaults the join table name and the source field name OneToManyAccessor - processUnidirectionalOneToManyMapping - defaults the pk field and table. MappingAccessor - processAssociationOverride and updatePrimaryKeyField. ObjectAccessor - processId
 */
@Override public MetadataDescriptor getOwningDescriptor(){
  return getOwningDescriptors().get(0);
}

Fixed version (ground truth):
/** 
 * INTERNAL: So, here's the deal ... this method typically gets called when defaulting  pk's name, primary table names etc. for various mappings. The problem  however is that we go beyond the spec and allow more mappings to be  specified on embeddable classes. For example, a M-M would default its  join table and join columns using the info from its owning descriptor.  The problem then is ... what to do when this embedabble has multiple  owning descriptors? That is, is shared. Right now, their pk names from  the owners better be same or mappings must be fully specified and not use  any defaults. I think that is somewhat ok given we're going beyond the  spec and TopLink doesn't even support it anyway??? So the stance is, we'll allow the extra mappings on embeddables that are  not shared, however on shared cases there are restrictions. Users should  use mapped superclasses when they have a need to share complex  embeddables. Or they can write customizers to modify their embeddable descriptors  after initialize (after they have been cloned) Future: the metadata processing 'could' set all necessary (per owning  descriptor) metadata and have the descriptor initialize code handle it. Metadata processing would process embeddable classes as it currently does  for MappedSuperclasses. Clone them and process under each owning entity  context. At descriptor initialize time, we would avoid cloning the  aggregate descriptor and use the one metadata processing provided.  Investigate further at a later date ... Callers to this method are ... BasicCollectionAccessor - processCollectionTable - defaults pk names from the owning descriptor. RelationshipAccessor - processJoinTable - defaults the join table name and the source field name OneToManyAccessor - processUnidirectionalOneToManyMapping - defaults the pk field and table. MappingAccessor - processAssociationOverride and updatePrimaryKeyField. ObjectAccessor - processId
 */
@Override public MetadataDescriptor getOwningDescriptor(){
  if (getOwningDescriptors() != null && getOwningDescriptors().size() > 0) {
    return getOwningDescriptors().get(0);
  }
  return this.getDescriptor();
}