Program: 104900
Project: 104900
Buggy source:
void mapReferencesFromDBObject(BasicDBObject dbObject,MappedField mf,Object entity){
  String name=mf.getName();
  Class fieldType=mf.getType();
  try {
    if (mf.isMap()) {
      Class referenceObjClass=mf.getSubType();
      Map map=(Map)tryConstructor(HashMap.class,mf.getCTor());
      if (dbObject.containsField(name)) {
        BasicDBObject dbVal=(BasicDBObject)dbObject.get(name);
        for (        Map.Entry entry : dbVal.entrySet()) {
          DBRef dbRef=(DBRef)entry.getValue();
          BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
          if (refDbObject != null) {
            Object refObj=createInstance(referenceObjClass,refDbObject);
            refObj=mapDBObjectToEntity(refDbObject,refObj);
            map.put(entry.getKey(),refObj);
          }
        }
      }
      mf.setFieldValue(entity,map);
    }
 else     if (mf.isMultipleValues()) {
      Class referenceObjClass=mf.getSubType();
      Collection references=(Collection)tryConstructor((!mf.isSet()) ? ArrayList.class : HashSet.class,mf.getCTor());
      if (dbObject.containsField(name)) {
        Object dbVal=dbObject.get(name);
        if (dbVal instanceof List) {
          List refList=(List)dbVal;
          for (          Object dbRefObj : refList) {
            DBRef dbRef=(DBRef)dbRefObj;
            BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
            if (refDbObject != null) {
              Object refObj=createInstance(referenceObjClass,refDbObject);
              refObj=mapDBObjectToEntity(refDbObject,refObj);
              references.add(refObj);
            }
          }
        }
 else {
          DBRef dbRef=(DBRef)dbObject.get(name);
          BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
          if (refDbObject != null) {
            Object newEntity=createInstance(referenceObjClass,refDbObject);
            newEntity=mapDBObjectToEntity(refDbObject,newEntity);
            references.add(newEntity);
          }
        }
      }
      mf.setFieldValue(entity,references);
    }
 else {
      Class referenceObjClass=fieldType;
      if (dbObject.containsField(name)) {
        DBRef dbRef=(DBRef)dbObject.get(name);
        BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
        if (refDbObject != null) {
          Object refObj=createInstance(referenceObjClass,refDbObject);
          refObj=mapDBObjectToEntity(refDbObject,refObj);
          mf.setFieldValue(entity,refObj);
        }
      }
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
void mapReferencesFromDBObject(BasicDBObject dbObject,MappedField mf,Object entity){
  String name=mf.getName();
  Class fieldType=mf.getType();
  try {
    Reference refAnn=mf.getAnnotation(Reference.class);
    if (mf.isMap()) {
      Class referenceObjClass=mf.getSubType();
      Map map=(Map)tryConstructor(HashMap.class,mf.getCTor());
      if (dbObject.containsField(name)) {
        BasicDBObject dbVal=(BasicDBObject)dbObject.get(name);
        for (        Map.Entry entry : dbVal.entrySet()) {
          DBRef dbRef=(DBRef)entry.getValue();
          BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
          if (refDbObject == null) {
            if (!refAnn.ignoreMissing())             throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
          }
 else {
            Object refObj=createInstance(referenceObjClass,refDbObject);
            refObj=mapDBObjectToEntity(refDbObject,refObj);
            map.put(entry.getKey(),refObj);
          }
        }
      }
      mf.setFieldValue(entity,map);
    }
 else     if (mf.isMultipleValues()) {
      Class referenceObjClass=mf.getSubType();
      Collection references=(Collection)tryConstructor((!mf.isSet()) ? ArrayList.class : HashSet.class,mf.getCTor());
      if (dbObject.containsField(name)) {
        Object dbVal=dbObject.get(name);
        if (dbVal instanceof List) {
          List refList=(List)dbVal;
          for (          Object dbRefObj : refList) {
            DBRef dbRef=(DBRef)dbRefObj;
            BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
            if (refDbObject == null) {
              if (!refAnn.ignoreMissing())               throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
            }
 else {
              Object refObj=createInstance(referenceObjClass,refDbObject);
              refObj=mapDBObjectToEntity(refDbObject,refObj);
              references.add(refObj);
            }
          }
        }
 else {
          DBRef dbRef=(DBRef)dbObject.get(name);
          BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
          if (refDbObject == null) {
            if (!refAnn.ignoreMissing())             throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
          }
 else {
            Object newEntity=createInstance(referenceObjClass,refDbObject);
            newEntity=mapDBObjectToEntity(refDbObject,newEntity);
            references.add(newEntity);
          }
        }
      }
      mf.setFieldValue(entity,references);
    }
 else {
      Class referenceObjClass=fieldType;
      if (dbObject.containsField(name)) {
        DBRef dbRef=(DBRef)dbObject.get(name);
        BasicDBObject refDbObject=(BasicDBObject)dbRef.fetch();
        if (refDbObject == null) {
          if (!refAnn.ignoreMissing())           throw new MappingException("String_Node_Str" + dbRef.toString() + "String_Node_Str"+ mf.getFullName());
        }
 else {
          Object refObj=createInstance(referenceObjClass,refDbObject);
          refObj=mapDBObjectToEntity(refDbObject,refObj);
          mf.setFieldValue(entity,refObj);
        }
      }
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}