Program: 67576
Project: 67576
Buggy source:
public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  if (this.fieldToClassMappings.size() == 0) {
    this.convertClassNamesToClasses(((XMLConversionManager)session.getDatasourcePlatform().getConversionManager()).getLoader());
  }
  Iterator<XMLField> fields=getFieldToClassMappings().keySet().iterator();
  while (fields.hasNext()) {
    XMLField next=fields.next();
    Converter converter=null;
    if (fieldsToConverters != null) {
      converter=fieldsToConverters.get(next);
    }
    if (next.getLastXPathFragment().nameIsText()) {
      XMLCompositeDirectCollectionMapping xmlMapping=new XMLCompositeDirectCollectionMapping();
      xmlMapping.setAttributeName(this.getAttributeName());
      xmlMapping.setAttributeAccessor(this.getAttributeAccessor());
      xmlMapping.setAttributeElementClass(getFieldToClassMappings().get(next));
      XMLConversionManager xmlConversionManager=(XMLConversionManager)session.getDatasourcePlatform().getConversionManager();
      QName schemaType=(QName)xmlConversionManager.getDefaultJavaTypes().get(xmlMapping.getAttributeElementClass());
      if (schemaType != null) {
        next.setSchemaType(schemaType);
      }
      xmlMapping.setField(next);
      xmlMapping.setDescriptor(this.getDescriptor());
      xmlMapping.setContainerPolicy(getContainerPolicy());
      if (converter != null) {
        xmlMapping.setValueConverter(converter);
      }
      this.choiceElementMappings.put(next,xmlMapping);
      xmlMapping.initialize(session);
    }
 else {
      XMLCompositeCollectionMapping xmlMapping=new XMLCompositeCollectionMapping();
      xmlMapping.setAttributeName(this.getAttributeName());
      xmlMapping.setAttributeAccessor(this.getAttributeAccessor());
      Class refClass=getFieldToClassMappings().get(next);
      if (!refClass.equals(ClassConstants.OBJECT)) {
        xmlMapping.setReferenceClass(refClass);
      }
      xmlMapping.setField(next);
      xmlMapping.setDescriptor(this.getDescriptor());
      xmlMapping.setContainerPolicy(getContainerPolicy());
      if (converter != null) {
        xmlMapping.setConverter(converter);
      }
      this.choiceElementMappings.put(next,xmlMapping);
      xmlMapping.initialize(session);
    }
  }
}

Fixed version (ground truth):
public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  if (this.fieldToClassMappings.size() == 0) {
    this.convertClassNamesToClasses(((XMLConversionManager)session.getDatasourcePlatform().getConversionManager()).getLoader());
  }
  Iterator<XMLMapping> mappings=getChoiceElementMappings().values().iterator();
  while (mappings.hasNext()) {
    DatabaseMapping nextMapping=(DatabaseMapping)mappings.next();
    nextMapping.setDescriptor(getDescriptor());
    nextMapping.setAttributeAccessor(this.getAttributeAccessor());
    nextMapping.setAttributeName(this.getAttributeName());
    Converter converter=null;
    if (fieldsToConverters != null) {
      converter=fieldsToConverters.get(nextMapping.getField());
    }
    if (nextMapping.isAbstractCompositeDirectCollectionMapping()) {
      XMLConversionManager xmlConversionManager=(XMLConversionManager)session.getDatasourcePlatform().getConversionManager();
      QName schemaType=(QName)xmlConversionManager.getDefaultJavaTypes().get(((AbstractCompositeDirectCollectionMapping)nextMapping).getAttributeElementClass());
      if (schemaType != null) {
        ((XMLField)nextMapping.getField()).setSchemaType(schemaType);
      }
      if (converter != null) {
        ((AbstractCompositeDirectCollectionMapping)nextMapping).setValueConverter(converter);
      }
      ((AbstractCompositeDirectCollectionMapping)nextMapping).setContainerPolicy(getContainerPolicy());
    }
 else {
      if (converter != null) {
        ((AbstractCompositeCollectionMapping)nextMapping).setConverter(converter);
      }
      ((AbstractCompositeCollectionMapping)nextMapping).setContainerPolicy(getContainerPolicy());
    }
    nextMapping.initialize(session);
  }
}