Program: 104905
Project: 104905
Buggy source:
void mapEmbeddedFromDBObject(BasicDBObject dbObject,MappedField mf,Object entity){
  String name=mf.getName();
  Class fieldType=mf.getType();
  try {
    if (mf.isMap()) {
      Map map=(Map)tryConstructor(HashMap.class,mf.getCTor());
      if (dbObject.containsField(name)) {
        BasicDBObject dbVal=(BasicDBObject)dbObject.get(name);
        for (        Map.Entry entry : dbVal.entrySet()) {
          Object newEntity=createInstance(mf.getSubType(),(BasicDBObject)entry.getValue());
          newEntity=mapDBObjectToEntity((BasicDBObject)entry.getValue(),newEntity);
          Object objKey=objectFromValue(mf.getMapKeyType(),entry.getKey());
          map.put(objKey,newEntity);
        }
      }
      if (map.size() > 0)       mf.setFieldValue(entity,map);
    }
 else     if (mf.isMultipleValues()) {
      Class newEntityType=mf.getSubType();
      Collection entities=(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 docDbObject : refList) {
            Object newEntity=createInstance(newEntityType,(BasicDBObject)docDbObject);
            newEntity=mapDBObjectToEntity((BasicDBObject)docDbObject,newEntity);
            entities.add(newEntity);
          }
        }
 else {
          BasicDBObject dbObj=(BasicDBObject)dbObject.get(name);
          Object newEntity=createInstance(newEntityType,dbObj);
          newEntity=mapDBObjectToEntity(dbObj,newEntity);
          entities.add(newEntity);
        }
      }
      if (entities.size() > 0)       mf.setFieldValue(entity,entities);
    }
 else {
      if (dbObject.containsField(name)) {
        BasicDBObject dbVal=(BasicDBObject)dbObject.get(name);
        Object refObj=createInstance(fieldType,dbVal);
        refObj=mapDBObjectToEntity(dbVal,refObj);
        if (refObj != null)         mf.setFieldValue(entity,refObj);
      }
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
void mapEmbeddedFromDBObject(BasicDBObject dbObject,MappedField mf,Object entity){
  String name=mf.getName();
  Class fieldType=mf.getType();
  try {
    if (mf.isMap()) {
      Map map=(Map)tryConstructor(HashMap.class,mf.getCTor());
      if (dbObject.containsField(name)) {
        BasicDBObject dbVal=(BasicDBObject)dbObject.get(name);
        for (        Map.Entry entry : dbVal.entrySet()) {
          Object newEntity=createInstance(mf.getSubType(),(BasicDBObject)entry.getValue());
          newEntity=mapDBObjectToEntity((BasicDBObject)entry.getValue(),newEntity);
          Object objKey=objectFromValue(mf.getMapKeyType(),entry.getKey());
          map.put(objKey,newEntity);
        }
      }
      if (map.size() > 0)       mf.setFieldValue(entity,map);
    }
 else     if (mf.isMultipleValues()) {
      Class newEntityType=mf.getSubType();
      Collection values=(Collection)tryConstructor((!mf.isSet()) ? ArrayList.class : HashSet.class,mf.getCTor());
      if (dbObject.containsField(name)) {
        Object dbVal=dbObject.get(name);
        List<BasicDBObject> dbVals=(dbVal instanceof List) ? (List<BasicDBObject>)dbVal : Collections.singletonList((BasicDBObject)dbVal);
        for (        BasicDBObject dbObj : dbVals) {
          Object newEntity=createInstance(newEntityType,dbObj);
          newEntity=mapDBObjectToEntity(dbObj,newEntity);
          values.add(newEntity);
        }
      }
      if (values.size() > 0)       if (mf.getType().isArray()) {
        Object[] array=convertToArray(mf.getSubType(),values);
        mf.setFieldValue(entity,array);
      }
 else       mf.setFieldValue(entity,values);
    }
 else {
      if (dbObject.containsField(name)) {
        BasicDBObject dbVal=(BasicDBObject)dbObject.get(name);
        Object refObj=createInstance(fieldType,dbVal);
        refObj=mapDBObjectToEntity(dbVal,refObj);
        if (refObj != null)         mf.setFieldValue(entity,refObj);
      }
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}