1

hibernate.cfg

<session-factory>

<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.ogm.datastore.provider">MONGODB</property>
<property name="hibernate.ogm.mongodb.database">rcfdb</property>
<property name="hibernate.ogm.mongodb.host">127.0.0.1</property>
<property name="hibernate.ogm.mongodb.port">27017</property>

<property name="hibernate.search.default.directory_provider">filesystem</property>    
<property name="hibernate.search.default.indexBase">./Indexes</property>    
<property name="hibernate.search.default.locking_strategy">single</property>
     <mapping resource="beanDao.hbm.xml"/>

</session-factory>

Getting error with the above hibernate.cfg. Unable to connect to mongoDB.

Davide D'Alto
  • 7,421
  • 2
  • 16
  • 30
Doomon
  • 43
  • 6
  • I have no knowledge of hibernate, but from what I can see your config lacks basic authentication parameters - username and password. – GSazheniuk Apr 17 '17 at 17:33

1 Answers1

0

As pointed out in the comments, you need to set the credentials and the authentication database; these are the properties:

hibernate.ogm.datastore.username
hibernate.ogm.datastore.password
hibernate.ogm.mongodb.authentication_database

You can find the list of properties for MongoDB in the official Hibernate OGM documentation: https://docs.jboss.org/hibernate/stable/ogm/reference/en-US/html_single/#_configuring_mongodb

Davide D'Alto
  • 7,421
  • 2
  • 16
  • 30