2017-04-17 2 views
1

hibernate.cfgJ'ai besoin de connecter hibernate avec mongoDB. Veuillez fournir le fichier hibernate.cfg pour mongoDB. J'ai une, mais sa ne fonctionne pas

<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> 

Obtenir erreur avec le hibernate.cfg ci-dessus. Impossible de se connecter à mongoDB.

+0

Je connais pas de mise en veille prolongée, mais de ce que je peux voir votre config manque l'authentification de base paramètres - nom d'utilisateur et mot de passe. – GSazheniuk

Répondre

0

Comme indiqué dans les commentaires, vous devez définir les informations d'identification et la base de données d'authentification; ce sont les propriétés:

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

Vous pouvez trouver la liste des propriétés pour MongoDB dans la documentation officielle Hibernate OGM: https://docs.jboss.org/hibernate/stable/ogm/reference/en-US/html_single/#_configuring_mongodb