Program: 66369
Project: 66369
Buggy source:
@Override public void writeFromObjectIntoRow(Object object,AbstractRecord row,AbstractSession session,WriteType writeType) throws DescriptorException {
  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());
    }
    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);
  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());
    }
    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);
}