I've found a strange problem (maybe a bug) that is caused when a database on MongoDB is created by an external program
Basically i've created on my Centos Linux a mongoDB database. I've deployed my war that points to that DB and i receive
OGM001219: Database "envi" does not exist. Either create it yourself or set property 'hibernate.ogm.datastore.create_database' to true.
But the database exists and i can connect with my mongo client. Not only. The connection was successfully established by java code (i can see the connection in mongod.log) but the code was failing during
.buildMetadata() in this code:
Code:
serviceRegistry = new StandardServiceRegistryBuilder()
.applySetting( OgmProperties.ENABLED, true )
.applySetting( OgmProperties.DATASTORE_PROVIDER, MongoDB.DATASTORE_PROVIDER_NAME )
.applySetting( OgmProperties.DATABASE, "envi")
.applySetting( OgmProperties.USERNAME, "envi")
.applySetting( OgmProperties.PASSWORD, "envi")
.applySetting( OgmProperties.CREATE_DATABASE, "true")
.applySetting( AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, "true")
.build();
try {
sessionFactory = new MetadataSources( serviceRegistry )
.addAnnotatedClass( Utenti.class )
.addAnnotatedClass( Roles.class )
.addAnnotatedClass( Categories.class )
.addAnnotatedClass( Reports.class)
.buildMetadata()
.getSessionFactoryBuilder()
.unwrap( OgmSessionFactoryBuilder.class )
.build();
} catch (Exception e) {
StandardServiceRegistryBuilder.destroy(serviceRegistry);
e.printStackTrace();
}
So i've decided to set that property to true and i get no more errors. The driver has recognized the database, has also created the indexes on the existent tables but then the tables has been erased... Can this could be a bug?