Wildfly上的多个持久性单元

时间:2017-02-03 17:00:32

标签: java jpa persistence.xml

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

<persistence-unit name="ContiegoDS" transaction-type="JTA">
    <jta-data-source>java:jboss/datasources/ContiegoDS</jta-data-source>
    <mapping-file>META-INF/orm.xml</mapping-file>
    <mapping-file>META-INF/orm-legacy.xml</mapping-file>
    <mapping-file>META-INF/queries/native.xml</mapping-file>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.mysql.MySQLSpatial56Dialect" />
        <property name="hibernate.globally_quoted_identifiers" value="true"/>
        <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.show_sql" value="true" />

    </properties>   
</persistence-unit>

<persistence-unit name="ContiegoWebsiteDS" transaction-type="JTA">
    <jta-data-source>java:jboss/datasources/ContiegoWebsiteDS</jta-data-source>
    <mapping-file>META-INF/orm-website.xml</mapping-file>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.mysql.MySQLSpatial56Dialect" />
        <property name="hibernate.globally_quoted_identifiers" value="true"/>
        <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.show_sql" value="true" />
    </properties>   
</persistence-unit>

我这样称呼

public class ContiegoEJB {

   @PersistenceContext(unitName="ContiegoDS")
   protected EntityManager contiegoEntityManager;

   @PersistenceContext(unitName="ContiegoWebsiteDS")
   protected EntityManager contiegoWebsiteEntityManager;

   public ContiegoEJB() {
   }

}

但我收到此错误

Here is the error log I can't post more code-text in the question

orm和orm-website.xml文件之间的比较

enter image description here

AdminUser和AdminUserPasswordRecovery实体...... AdminUser and AdminUserPasswordRecovery entities.

从AdminUserPasswordRecoveryRequest到AdminUser的多对一关系 enter image description here

我可能做错什么?

0 个答案:

没有答案