final RecursiveParent parent = new RecursiveParent();
final DBObject parentDbObj = getMorphia().toDBObject(parent);
stuff.save(parentDbObj);
final RecursiveChild child = new RecursiveChild();
final DBObject childDbObj = getMorphia().toDBObject(child);
stuff.save(childDbObj);
final RecursiveParent parentLoaded = getMorphia().fromDBObject(RecursiveParent.class,
stuff.findOne(new BasicDBObject(Mapper.ID_KEY,
parentDbObj.get(Mapper.ID_KEY))),
new DefaultEntityCache());
final RecursiveChild childLoaded = getMorphia().fromDBObject(RecursiveChild.class,
stuff.findOne(new BasicDBObject(Mapper.ID_KEY,
childDbObj.get(Mapper.ID_KEY))),
new DefaultEntityCache());
parentLoaded.setChild(childLoaded);
childLoaded.setParent(parentLoaded);
stuff.save(getMorphia().toDBObject(parentLoaded));
stuff.save(getMorphia().toDBObject(childLoaded));
final RecursiveParent finalParentLoaded = getMorphia().fromDBObject(RecursiveParent.class,
stuff.findOne(new BasicDBObject(Mapper.ID_KEY,
parentDbObj.get(Mapper
.ID_KEY))),
new DefaultEntityCache());
final RecursiveChild finalChildLoaded = getMorphia().fromDBObject(RecursiveChild.class,
stuff.findOne(new BasicDBObject(Mapper.ID_KEY,
childDbObj.get(Mapper.ID_KEY))),
new DefaultEntityCache());
assertNotNull(finalParentLoaded.getChild());
assertNotNull(finalChildLoaded.getParent());
}