public static synchronized Morphia getMorphia() throws Exception { if (morphia == null) { mongo = getMongo(); morphia = new Morphia(); morphia.mapPackage("org.zkoss.mongodb.model"); } return morphia; }
@Provides Morphia createMorphia(final Application application) { Morphia morphia = new Morphia(); morphia.getMapper().getOptions().objectFactory = new DefaultCreator() { @Override protected ClassLoader getClassLoaderForClass(String clazz, DBObject object) { return application.classloader(); } }; morphia.mapPackage("models"); return morphia; }