Program: 65633
Project: 65633
Buggy source:
@Override public void writeFromObjectIntoRow(Object object,AbstractRecord row,AbstractSession session,WriteType writeType) throws DescriptorException {
  if (this.isReadOnly()) {
    return;
  }
  Object attributeValue=getAttributeValueFromObject(object);
  List<XMLEntry> nestedRows=new ArrayList<XMLEntry>();
  XMLRecord record=(XMLRecord)row;
  ContainerPolicy cp=getContainerPolicy();
  Object iterator=cp.iteratorFor(attributeValue);
  while (cp.hasNext(iterator)) {
    Object value=cp.next(iterator,session);
    if (null != converter) {
      if (converter instanceof XMLConverter) {
        value=((XMLConverter)converter).convertObjectValueToDataValue(value,session,record.getMarshaller());
      }
 else {
        value=converter.convertObjectValueToDataValue(value,session);
      }
    }
    NodeValue associatedNodeValue=null;
    XMLField associatedField=null;
    Object fieldValue=value;
    if (value instanceof XMLRoot) {
      XMLRoot rootValue=(XMLRoot)value;
      String localName=rootValue.getLocalName();
      String namespaceUri=rootValue.getNamespaceURI();
      fieldValue=rootValue.getObject();
      associatedField=getFieldForName(localName,namespaceUri);
      if (associatedField == null) {
        associatedField=getClassToFieldMappings().get(fieldValue.getClass());
      }
    }
 else {
      associatedField=getClassToFieldMappings().get(value.getClass());
    }
    if (associatedField == null) {
      List<XMLField> sourceFields=classToSourceFieldsMappings.get(value.getClass());
      if (sourceFields != null && sourceFields.size() > 0) {
        DatabaseMapping xmlMapping=(DatabaseMapping)this.choiceElementMappings.get(sourceFields.get(0));
        for (        XMLField next : sourceFields) {
          fieldValue=((XMLCollectionReferenceMapping)xmlMapping).buildFieldValue(value,next,session);
          XMLEntry entry=new XMLEntry();
          entry.setValue(fieldValue);
          entry.setXMLField(next);
          nestedRows.add(entry);
        }
      }
    }
 else {
      DatabaseMapping xmlMapping=(DatabaseMapping)this.choiceElementMappings.get(associatedField);
      if (xmlMapping.isAbstractCompositeCollectionMapping()) {
        fieldValue=((XMLCompositeCollectionMapping)xmlMapping).buildCompositeRow(fieldValue,session,row,writeType);
      }
      XMLEntry entry=new XMLEntry();
      entry.setValue(fieldValue);
      entry.setXMLField(associatedField);
      nestedRows.add(entry);
    }
  }
  ((DOMRecord)row).put(getFields(),nestedRows);
}

Fixed version (ground truth):
@Override public void writeFromObjectIntoRow(Object object,AbstractRecord row,AbstractSession session,WriteType writeType) throws DescriptorException {
  if (this.isReadOnly()) {
    return;
  }
  Object attributeValue=getAttributeValueFromObject(object);
  List<XMLEntry> nestedRows=new ArrayList<XMLEntry>();
  XMLRecord record=(XMLRecord)row;
  ContainerPolicy cp=getContainerPolicy();
  Object iterator=cp.iteratorFor(attributeValue);
  if (null != iterator) {
    while (cp.hasNext(iterator)) {
      Object value=cp.next(iterator,session);
      if (null != converter) {
        if (converter instanceof XMLConverter) {
          value=((XMLConverter)converter).convertObjectValueToDataValue(value,session,record.getMarshaller());
        }
 else {
          value=converter.convertObjectValueToDataValue(value,session);
        }
      }
      NodeValue associatedNodeValue=null;
      XMLField associatedField=null;
      Object fieldValue=value;
      if (value instanceof XMLRoot) {
        XMLRoot rootValue=(XMLRoot)value;
        String localName=rootValue.getLocalName();
        String namespaceUri=rootValue.getNamespaceURI();
        fieldValue=rootValue.getObject();
        associatedField=getFieldForName(localName,namespaceUri);
        if (associatedField == null) {
          associatedField=getClassToFieldMappings().get(fieldValue.getClass());
        }
      }
 else {
        associatedField=getClassToFieldMappings().get(value.getClass());
      }
      if (associatedField == null) {
        List<XMLField> sourceFields=classToSourceFieldsMappings.get(value.getClass());
        if (sourceFields != null && sourceFields.size() > 0) {
          DatabaseMapping xmlMapping=(DatabaseMapping)this.choiceElementMappings.get(sourceFields.get(0));
          for (          XMLField next : sourceFields) {
            fieldValue=((XMLCollectionReferenceMapping)xmlMapping).buildFieldValue(value,next,session);
            XMLEntry entry=new XMLEntry();
            entry.setValue(fieldValue);
            entry.setXMLField(next);
            nestedRows.add(entry);
          }
        }
      }
 else {
        DatabaseMapping xmlMapping=(DatabaseMapping)this.choiceElementMappings.get(associatedField);
        if (xmlMapping.isAbstractCompositeCollectionMapping()) {
          fieldValue=((XMLCompositeCollectionMapping)xmlMapping).buildCompositeRow(fieldValue,session,row,writeType);
        }
        XMLEntry entry=new XMLEntry();
        entry.setValue(fieldValue);
        entry.setXMLField(associatedField);
        nestedRows.add(entry);
      }
    }
  }
  ((DOMRecord)row).put(getFields(),nestedRows);
}