public HirundoDatastore() { MongoClient mongo = new MongoClient("localhost", 27017); Morphia morphia = new Morphia(); morphia.mapPackage("mongoEntities"); datastore = morphia.createDatastore(mongo, "hirundo"); datastore.ensureIndexes(); }
private MorphiaSingleton() { IPropertiesConfiguration configdb = FactoryBeans.getInstance(ConfigurationSpring.class).getBean(IPropertiesConfiguration.class); mongoClient = new MongoClient( configdb.getItem(IPropertiesConfiguration.MONGO_DBHOST), Integer.valueOf(configdb.getItem(IPropertiesConfiguration.MONGO_DBPORT))); morphia = new Morphia(); morphia.getMapper().getConverters().addConverter(BigDecimalConverter.class); morphia.mapPackage("com.paymet.rest.main.db.bean"); datastore = morphia.createDatastore( mongoClient, configdb.getItem(IPropertiesConfiguration.MONGO_DBNAME)); datastore.ensureIndexes(); }
/** * Create Datastore. * * @param dbName * @return */ public Datastore createDataStore(String dbName) { return morphia.createDatastore(mongo, dbName); }
public MongodbQueryTest() throws UnknownHostException, MongoException { mongo = new Mongo(); morphia = new Morphia().map(User.class).map(Item.class).map(MapEntity.class).map(Dates.class); ds = morphia.createDatastore(mongo, dbname); }