Program: 66005
Project: 66005
Buggy source:
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  if (value instanceof XMLRoot) {
    XMLRoot root=(XMLRoot)value;
    XPathFragment fragment=this.xmlField.getXPathFragment();
    while (fragment != null && !fragment.nameIsText) {
      if (fragment.getNextFragment() == null || fragment.getHasText()) {
        if (fragment.getLocalName().equals(root.getLocalName())) {
          String fragUri=fragment.getNamespaceURI();
          String namespaceUri=root.getNamespaceURI();
          if ((namespaceUri == null && fragUri == null) || (namespaceUri != null && fragUri != null && namespaceUri.equals(fragUri))) {
            return this.choiceElementNodeValue.marshalSingleValue(xPathFragment,marshalRecord,object,value,session,namespaceResolver,marshalContext);
          }
        }
      }
      fragment=fragment.getNextFragment();
    }
  }
 else   if (value != null) {
    if (xmlChoiceMapping.getClassToFieldMappings().get(value.getClass()) == this.xmlField) {
      return this.choiceElementNodeValue.marshalSingleValue(xPathFragment,marshalRecord,object,value,session,namespaceResolver,marshalContext);
    }
    List<XMLField> sourceFields=xmlChoiceMapping.getClassToSourceFieldsMappings().get(value.getClass());
    if (sourceFields != null && sourceFields.contains(this.xmlField)) {
      return this.choiceElementNodeValue.marshalSingleValue(xPathFragment,marshalRecord,object,value,session,namespaceResolver,marshalContext);
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  Class valueClass=null;
  if (value instanceof XMLRoot) {
    XMLRoot root=(XMLRoot)value;
    for (    DatabaseField next : this.xmlChoiceMapping.getFields()) {
      XPathFragment fragment=((XMLField)next).getXPathFragment();
      while (fragment != null && !fragment.nameIsText) {
        if (fragment.getNextFragment() == null || fragment.getHasText()) {
          if (fragment.getLocalName().equals(root.getLocalName())) {
            String fragUri=fragment.getNamespaceURI();
            String namespaceUri=root.getNamespaceURI();
            if ((namespaceUri == null && fragUri == null) || (namespaceUri != null && fragUri != null && namespaceUri.equals(fragUri))) {
              if (next == this.xmlField) {
                return this.choiceElementNodeValue.marshalSingleValue(xPathFragment,marshalRecord,object,value,session,namespaceResolver,marshalContext);
              }
 else {
                return false;
              }
            }
          }
        }
        fragment=fragment.getNextFragment();
      }
    }
    valueClass=root.getObject().getClass();
  }
  if (value != null) {
    if (valueClass == null) {
      valueClass=value.getClass();
    }
    if (xmlChoiceMapping.getClassToFieldMappings().get(valueClass) == this.xmlField) {
      return this.choiceElementNodeValue.marshalSingleValue(xPathFragment,marshalRecord,object,value,session,namespaceResolver,marshalContext);
    }
    List<XMLField> sourceFields=xmlChoiceMapping.getClassToSourceFieldsMappings().get(valueClass);
    if (sourceFields != null && sourceFields.contains(this.xmlField)) {
      return this.choiceElementNodeValue.marshalSingleValue(xPathFragment,marshalRecord,object,value,session,namespaceResolver,marshalContext);
    }
  }
  return false;
}