Hibernate mongodb配置文件

时间:2015-10-21 00:13:41

标签: mongodb hibernate

<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说不需要方言。但我有错误

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)

1 个答案:

答案 0 :(得分:2)

首先,我认为您的配置是错误的。您使用的比例应放在persistence.xml文件中。示例是here

描述所需的属性为here