Program: 64174
Project: 64174
Buggy source:
@Override public void postInitialize(AbstractSession session) throws DescriptorException {
  DatabaseMapping mapping=getReferenceDescriptor().getMappingForAttributeName(this.mappedBy);
  if (mapping instanceof XMLCompositeCollectionMapping) {
    XMLCompositeCollectionMapping oppositeMapping=(XMLCompositeCollectionMapping)mapping;
    oppositeMapping.setInverseReferenceMapping(this);
  }
  if (mapping instanceof XMLCompositeObjectMapping) {
    XMLCompositeObjectMapping oppositeMapping=(XMLCompositeObjectMapping)mapping;
    oppositeMapping.setInverseReferenceMapping(this);
  }
  if (mapping instanceof XMLObjectReferenceMapping) {
    XMLObjectReferenceMapping oppositeMapping=(XMLObjectReferenceMapping)mapping;
    oppositeMapping.setInverseReferenceMapping(this);
  }
  if (mapping instanceof XMLChoiceObjectMapping) {
    XMLChoiceObjectMapping oppositeMapping=(XMLChoiceObjectMapping)mapping;
    Collection<XMLMapping> nestedMappings=oppositeMapping.getChoiceElementMappings().values();
    for (    XMLMapping next : nestedMappings) {
      if (next instanceof XMLCompositeObjectMapping) {
        XMLCompositeObjectMapping compositeMapping=((XMLCompositeObjectMapping)next);
        if (compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass() || this.getDescriptor().getJavaClass().isAssignableFrom(compositeMapping.getReferenceClass())) {
          compositeMapping.setInverseReferenceMapping(this);
        }
      }
 else       if (next instanceof XMLObjectReferenceMapping) {
        XMLObjectReferenceMapping refMapping=((XMLObjectReferenceMapping)next);
        if (refMapping.getReferenceClass() == this.getDescriptor().getJavaClass()) {
          refMapping.setInverseReferenceMapping(this);
        }
      }
    }
  }
  if (mapping instanceof XMLChoiceCollectionMapping) {
    XMLChoiceCollectionMapping oppositeMapping=(XMLChoiceCollectionMapping)mapping;
    Collection<XMLMapping> nestedMappings=oppositeMapping.getChoiceElementMappings().values();
    for (    XMLMapping next : nestedMappings) {
      if (next instanceof XMLCompositeCollectionMapping) {
        XMLCompositeCollectionMapping compositeMapping=((XMLCompositeCollectionMapping)next);
        if (compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass() || this.getDescriptor().getJavaClass().isAssignableFrom(compositeMapping.getReferenceClass())) {
          compositeMapping.setInverseReferenceMapping(this);
        }
      }
 else       if (next instanceof XMLCollectionReferenceMapping) {
        XMLCollectionReferenceMapping refMapping=((XMLCollectionReferenceMapping)next);
        if (refMapping.getReferenceClass() == this.getDescriptor().getJavaClass()) {
          refMapping.setInverseReferenceMapping(this);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void postInitialize(AbstractSession session) throws DescriptorException {
  DatabaseMapping mapping=getReferenceDescriptor().getMappingForAttributeName(this.mappedBy);
  if (mapping instanceof XMLInverseReferenceMapping) {
    mapping=((XMLInverseReferenceMapping)mapping).getInlineMapping();
  }
  if (mapping instanceof XMLCompositeCollectionMapping) {
    XMLCompositeCollectionMapping oppositeMapping=(XMLCompositeCollectionMapping)mapping;
    oppositeMapping.setInverseReferenceMapping(this);
  }
  if (mapping instanceof XMLCompositeObjectMapping) {
    XMLCompositeObjectMapping oppositeMapping=(XMLCompositeObjectMapping)mapping;
    oppositeMapping.setInverseReferenceMapping(this);
  }
  if (mapping instanceof XMLObjectReferenceMapping) {
    XMLObjectReferenceMapping oppositeMapping=(XMLObjectReferenceMapping)mapping;
    oppositeMapping.setInverseReferenceMapping(this);
  }
  if (mapping instanceof XMLChoiceObjectMapping) {
    XMLChoiceObjectMapping oppositeMapping=(XMLChoiceObjectMapping)mapping;
    Collection<XMLMapping> nestedMappings=oppositeMapping.getChoiceElementMappings().values();
    for (    XMLMapping next : nestedMappings) {
      if (next instanceof XMLCompositeObjectMapping) {
        XMLCompositeObjectMapping compositeMapping=((XMLCompositeObjectMapping)next);
        if (compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass() || this.getDescriptor().getJavaClass().isAssignableFrom(compositeMapping.getReferenceClass())) {
          compositeMapping.setInverseReferenceMapping(this);
        }
      }
 else       if (next instanceof XMLObjectReferenceMapping) {
        XMLObjectReferenceMapping refMapping=((XMLObjectReferenceMapping)next);
        if (refMapping.getReferenceClass() == this.getDescriptor().getJavaClass()) {
          refMapping.setInverseReferenceMapping(this);
        }
      }
    }
  }
  if (mapping instanceof XMLChoiceCollectionMapping) {
    XMLChoiceCollectionMapping oppositeMapping=(XMLChoiceCollectionMapping)mapping;
    Collection<XMLMapping> nestedMappings=oppositeMapping.getChoiceElementMappings().values();
    for (    XMLMapping next : nestedMappings) {
      if (next instanceof XMLCompositeCollectionMapping) {
        XMLCompositeCollectionMapping compositeMapping=((XMLCompositeCollectionMapping)next);
        if (compositeMapping.getReferenceClass() == this.getDescriptor().getJavaClass() || this.getDescriptor().getJavaClass().isAssignableFrom(compositeMapping.getReferenceClass())) {
          compositeMapping.setInverseReferenceMapping(this);
        }
      }
 else       if (next instanceof XMLCollectionReferenceMapping) {
        XMLCollectionReferenceMapping refMapping=((XMLCollectionReferenceMapping)next);
        if (refMapping.getReferenceClass() == this.getDescriptor().getJavaClass()) {
          refMapping.setInverseReferenceMapping(this);
        }
      }
    }
  }
  if (inlineMapping != null) {
    inlineMapping.postInitialize(session);
  }
}