使用 Hibernate OGM Neo4j 设置 Play Framework 2.5.x

Setting up Play Framework 2.5.x with Hibernate OGM Neo4j

我正在尝试设置 Hibernate OGM 以与 Play Framework 2 一起使用。5.x(17) 在我的例子中,但我不断收到 "Cannot connect to database [default]" 错误。 Apparantly Play 默认采用 MySQL 驱动程序,我无法找到专门针对 Neo4J 的驱动程序配置。 这是我的 persistance.xml 文件内容:-

<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
         version="2.0">

<persistence-unit name="defaultPersistenceUnit" transaction-type="JTA">
    <!-- Use Hib77ernate OGM provider: configuration will be transparent -->

<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
    <non-jta-data-source>DefaultDS</non-jta-data-source>

        <properties>
            <property name="hibernate.transaction.jta.platform"
                  value="JBossTS" />
            <property name="hibernate.ogm.datastore.provider" value="neo4j_http"/>
            <property name="hibernate.ogm.datastore.host" value="localhost:7474"/>
            <property name="hibernate.ogm.datastore.username" value="neo4j"/>
            <property name="hibernate.ogm.datastore.password" value="neo4j"/>

        </properties>
    </persistence-unit>
</persistence>

和application.conf内容:

 db.default.jndiName=DefaultDS
    jpa{
      default=defaultPersistenceUnit
    }

感谢任何帮助。提前致谢。

我遇到了同样的问题,然后我找到了一个可以使用 neo4j jdbc 驱动程序的解决方案。

application.conf :-

db.default.jndiName=DefaultDS  
jpa.default=defaultPersistenceUnit  
db.default.driver=org.neo4j.jdbc.Driver  
db.default.url="jdbc:neo4j:http://localhost"  
db.default.user= neo4j  
db.default.password="password"

persistence.xml

http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" 版本="2.1">

<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
    <non-jta-data-source>DefaultDS</non-jta-data-source>
    <class>domain class name</class>
    <properties>
        <property name="hibernate.transaction.jta.platform"
                  value="JBossTS" />
        <property name="hibernate.ogm.datastore.provider" value="neo4j_http"/>
        <property name="hibernate.ogm.datastore.host" value="localhost:7474"/>
        <property name="hibernate.ogm.datastore.username" value="neo4j"/>
        <property name="hibernate.ogm.datastore.password" value="password"/>


    </properties>
</persistence-unit>