JPA - 多个持久性单元

时间:2016-02-29 18:10:45

标签: jpa persistence openjpa jta persistence.xml

我正在使用JPA,我正在连接多个数据库。下面是persistence.xml -

<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">

    <persistence-unit name="myRead" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
            <property name="hibernate.show_sql" value="true" />
        </properties>
    </persistence-unit>

    <persistence-unit name="myWrite" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <class>com.test.model.Person</class>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
            <property name="hibernate.show_sql" value="true" />
        </properties>
    </persistence-unit>

</persistence>

当加载Spring上下文时,它试图从Person持久性单元中查找myRead表。 Spring根本没有认识到第二个持久性单元。有人可以帮忙吗。

0 个答案:

没有答案