2015-10-21 141 views
0
<hibernate-configuration> 

    <session-factory> 

     <!-- Database connection settings --> 
     <property name="hibernate.ogm.datastore.provider">mongodb</property> 
     <property name="hibernate.ogm.datastore.host">127.0.0.1</property> 
     <property name="hibernate.ogm.datastore.port">27017</property> 
     <property name="hibernate.ogm.datastore.database">eatery</property> 
     <property name="hibernate.ogm.datastore.create_database">true</property> 


     <mapping class="com.ws.web.models.Reservation" /> 

    </session-factory> 

</hibernate-configuration> 

有誰知道鋤頭爲mongodb配置hibernate。 Docs表示不需要方言。但我得到的錯誤休眠mongodb配置文件

Exception in thread "main" org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set 
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104) 
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71) 
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:209) 
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) 
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845) 
    at com.ws.web.models.Test.main(Test.java:17) 

回答

2

首先,我認爲你的配置是錯誤的。您使用的屬性應放置在persistence.xml文件中。示例爲here

描述的必要屬性是here