-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: OGM001219 caused by invalid datastore.create_database
PostPosted: Sat Nov 19, 2016 5:37 am 
Newbie

Joined: Mon Nov 07, 2016 4:36 am
Posts: 3
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?


Top
 Profile  
 
 Post subject: Re: OGM001219 caused by invalid datastore.create_database
PostPosted: Tue Nov 22, 2016 6:22 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Thanks for the feedback,
I'll have a look, could you let me know which version of Hibernate OGM and MongdoDB are you using?

Thanks,
Davide


Top
 Profile  
 
 Post subject: Re: OGM001219 caused by invalid datastore.create_database
PostPosted: Tue Nov 22, 2016 7:22 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
I created a test trying to replicate your issue but it seems to work as expected.

You can see the test on github: https://github.com/DavideD/hibernate-og ... e3e35a55a2

Please let me know if I'm missing something.

By the way, you can also create the factory this way:

Code:
OgmConfiguration configuration = new OgmConfiguration();
configuration.addAnnotatedClass( Utenti.class );
...
SessionFactory sessionFactory = configuration.buildSessionFactory( serviceRegistry );


I think It's simpler beacuse it already enables OGM and does not need the unwrap call.

Davide


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.