2016-11-23 3 views
0
  1. 최대 절전 모드-OGM에 여러되는 NoSQL 데이터베이스에 연결하기 위해 내가 MongoDB를Neo4j에 연결해야, 어떻게 그것을 구성하는?
  2. MongodbMysql에 연결해야하는 경우 구성하는 방법은 무엇입니까?

답변

0

다른 지속성 단위를 정의해야합니다.

@PersistenceUnit(unitName = "neo4j-pu") 
EntityManagerFactory neo4jEMF; 

@PersistenceContext(unitName = "neo4j-pu") 
EntityManager neo4jEM; 
: 당신은 당신이 이름을 지정해야합니다 지속성 공장 또는 엔티티 관리자를 필요로 할 때이 시점에서

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>            
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" 
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> 
    <persistence-unit name="neo4j-pu">                 
    <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>        
    <properties>                      
     <property name="hibernate.ogm.datastore.provider" value="neo4j_http"/>           
     ... 
    </properties>                     
    </persistence-unit> 

    <persistence-unit name="mongodb-pu">                 
    <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>        
    <properties>                            
     <property name="hibernate.ogm.datastore.provider" value="MONGODB"/>       
     <property name="hibernate.ogm.datastore.database" value="ogm_test_database"/>     
     <property name="hibernate.ogm.datastore.create_database" value="true"/> 
     ... 
    </properties>                     
    </persistence-unit>      

    <persistence-unit name="mysql-pu">                 
    <provider>org.hibernate.ejb.HibernatePersistence</provider> 
    <properties>                            
     <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> 
     <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/jpatestdb" /> 
     ... 
    </properties>                     
    </persistence-unit>                  
</persistence>  

: 당신이 persistence.xml 파일을 사용하는 경우 예를 들어, 같은 모양 것

이것은 Hibernate ORM 또는 JPA에서 할 일과 다르지 않습니다. 네이티브 API를 통해이 작업을 수행 할 수도 있지만 아이디어가 있다고 생각합니다.

관련 문제