2011-06-20 7 views
0

Hibernate/JPAを使用して私のプロジェクト(Webアプリケーション)に3つのデータベースをマップする必要がありますので、3つの接続をサポートするためにpersistance.xmlを構成するにはどうすればいいですか? これは私のファイルです: persistance.xml同じ時刻に3つのデータベースをマップする

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.0" 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"> 
<persistence-unit name="JiraMapPU" transaction-type="RESOURCE_LOCAL"> 
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
<class>DTOKpi.AssociationKpiProfil</class> //from database1 
<class>DTOKpi.Kpi</class>     //database1 
<class>DTOKpi.ProfilUser</class>   // database1 
<class>DTOJIRA.Resolution</class>   // database2 
<class>DTOJIRA.Project</class>   // database2 
<class>DTOJIRA.Issuestatus</class> 
<class>DTOJIRA.Jiraissue</class> 
<class>DTOJIRA.Priority</class> 
<class>DTOJIRA.Component</class> 
<class>DTOJIRA.Issuetype</class> 
<exclude-unlisted-classes>false</exclude-unlisted-classes> 
<properties> 
    <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/jiradb"/> 
    <property name="javax.persistence.jdbc.password" value="root"/> 
    <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> 
    <property name="javax.persistence.jdbc.user" value="root"/> 
</properties> 

マイhibernate.cfg.xmlの

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
<session-factory> 
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jiradb</property> 
<property name="hibernate.connection.username">root</property> 
<mapping resource="DTOTest/issuestatus.hbm.xml"/> 
<mapping resource="hibernate.hbm.xml"/> 
</session-factory> 
</hibernate-configuration> 

私は便利なこのリンクを発見した:How do I connect to multiple databases using JPA?のが、あなたの3つのデータベースは、私はそれが動作すると思う同じですが、そうでなければ私はあなたがマップファイルを作成する必要があると思うなら、私は第二段階

答えて

1

を理解することができませんでしたデータベースごとに

+0

こんにちは私は解決策を見つけました、私は別のを2番目のデータベースに追加しました:) – ramram

関連する問題