morphia.map(Circle.class)
.map(Rectangle.class)
.map(ShapeShifter.class);
Shape rectangle = new Rectangle(2,5);
DBObject rectangleDbObj = morphia.toDBObject(rectangle);
shapes.save(rectangleDbObj);
BasicDBObject rectangleDbObjLoaded = (BasicDBObject) shapes.findOne(new BasicDBObject(Mapper.ID_KEY, rectangleDbObj.get(Mapper.ID_KEY)));
Shape rectangleLoaded = morphia.fromDBObject(Shape.class, rectangleDbObjLoaded, new DefaultEntityCache());
assertTrue(rectangle.getArea() == rectangleLoaded.getArea());
assertTrue(rectangleLoaded instanceof Rectangle);
ShapeShifter shifter = new ShapeShifter();
shifter.setReferencedShape(rectangleLoaded);
shifter.setMainShape(new Circle(2.2));