简体   繁体   English

如何将JPA实体与PersistenceUnits关联

[英]How to associate JPA entities with PersistenceUnits

I have two persistenceUnits mapping to two different Oracle schema, the schemas are similar but with different table names. 我有两个persistenceUnits映射到两个不同的Oracle模式,这些模式相似,但是表名不同。 When I try to deploy my application,I get a Hibernate Exception "Missing Table", it seems like Hibernate is looking for table in the wrong persistenceUnit. 当我尝试部署我的应用程序时,我收到一个Hibernate异常“ Missing Table”,似乎Hibernate在错误的persistenceUnit中寻找表。

.ear#POIPersistenceUnit\\": org.hibernate.HibernateException: Missing table: POI_SERVICE Caused by: org.hibernate.HibernateException: Missing table: POI_SERVICE"}} .ear#POIPersistenceUnit \\“:org.hibernate.HibernateException:缺少表:POI_SERVICE原因:org.hibernate.HibernateException:缺少表:POI_SERVICE”}}

the table "POI_SERVICE" belongs to "POIExtractorPersistenceUnit" persistenceUnit not "POIPersistenceUnit" persistenceUnit 表“ POI_SERVICE”属于“ POIExtractorPersistenceUnit” persistenceUnit,而不属于“ POIPersistenceUnit” persistenceUnit

I have tried listing the entities with the respective persistenceUnits in the persistence.xml file as follows but with no luck, still getting the same error. 我尝试按如下所示在persistence.xml文件中列出具有各个persistenceUnits的实体,但是没有运气,仍然出现相同的错误。

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">

<persistence-unit name="POIExtractorPersistenceUnit">

    <jta-data-source>java:/XAPOIExtractorDS</jta-data-source>

    <class>za.co.fnb.cii.poiextractor.persistence.model.IdentificationRequest</class>
    <class>za.co.fnb.cii.poiextractor.persistence.model.IdentificationResponse</class>
    <class>za.co.fnb.cii.poiextractor.persistence.model.POIService</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>

    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
        <property name="hibernate.archive.autodetection" value="class" />
        <property name="hibernate.flushMode" value="FLUSH_AUTO" />
        <property name="hibernate.hbm2ddl.auto" value="validate" />
        <property name="hibernate.show_sql" value="true" />

    </properties>

</persistence-unit>

<persistence-unit name="POIPersistenceUnit">

    <jta-data-source>java:/XACompendiumDS</jta-data-source>

    <class>za.co.fnb.cii.poiextractor.persistence.entities.IdentificationRequestIncoming</class>
    <class>za.co.fnb.cii.poiextractor.persistence.entities.IdentificationResponseIncoming</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>

    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
        <property name="hibernate.archive.autodetection" value="class" />
        <property name="hibernate.flushMode" value="FLUSH_AUTO" />
        <property name="hibernate.hbm2ddl.auto" value="validate" />
        <property name="hibernate.show_sql" value="false" />

    </properties>

</persistence-unit>

I have also tried to annotate the entities as follows @PersistenceUnit(unitName = "POIExtractorPersistenceUnit") but still no luck, the error is still there. 我也尝试按如下所示注释实体@PersistenceUnit(unitName = "POIExtractorPersistenceUnit")但仍然没有运气,错误仍然存​​在。

/**
 * Created by on 21-Dec-15.
 */
@Entity
@Table(name = "POI_SERVICE")
@PersistenceUnit(unitName = "POIExtractorPersistenceUnit")
@NamedQueries({
        @NamedQuery(name="findServiceRecordByApplicationName",
                query="SELECT pois FROM POIService pois WHERE pois.application = :applicationName")
})
public class POIService implements IEntity{

    @Id
    @GeneratedValue(generator="service_config_seq")
    @SequenceGenerator(name="service_config_seq", sequenceName="service_config_seq", allocationSize=1)
    private long id;

    private String application;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "last_update",nullable = false)
    private Date lastUpdate;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "last_date",nullable = true)
    private Date lastDate;

    @Column(name = "last_record",nullable = true)
    private long lastRecord;

    @Override
    public long getId() {
        return id;
    }

    public String getApplication() {
        return application;
    }

    public void setApplication(String application) {
        this.application = application;
    }

    public Date getLastUpdate() {
        return lastUpdate;
    }

    public void setLastUpdate(Date lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    public Date getLastDate() {
        return lastDate;
    }

    public void setLastDate(Date lastDate) {
        this.lastDate = lastDate;
    }

    public long getLastRecord() {
        return lastRecord;
    }

    public void setLastRecord(long lastRecord) {
        this.lastRecord = lastRecord;
    }
}

UPDATE: 更新:

Stacktrace 堆栈跟踪

2016-01-08 12:24:52,587 INFO [java.sql.DatabaseMetaData] (ServerService Thread Pool -- 58) HHH000262: Table not found: POI_SERVICE 2016-01-08 12:24:52,590 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 58) MSC000001: Failed to start service jboss.persistenceunit."poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit": org.jboss.msc.service.StartException in service jboss.persistenceunit."poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit": org.hibernate.HibernateException: Missing table: POI_SERVICE at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final] at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final] at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_60] at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474) [wildfly-s 2016-01-08 12:24:52,587信息[java.sql.DatabaseMetaData](ServerService线程池-58)HHH000262:找不到表:POI_SERVICE 2016-01-08 12:24:52,590错误[org.jboss.msc .service.fail](ServerService线程池-58)MSC000001:无法启动服务jboss.persistenceunit。“ poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit”:服务中的org.jboss.msc.service.StartException jboss.persistenceunit。“ poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit”:org.hibernate.HibernateException:缺少表:org.jboss.as.jpa.service.PersistenceUnitServiceImpl $ 1 $ 1.run(PersistenceUnitServiceImpl.java :172)[wildfly-jpa-8.2.0.Final.jar:8.2.0.Final] at org.jboss.as.jpa.service.PersistenceUnitServiceImpl $ 1 $ 1.run(PersistenceUnitServiceImpl.java:117)[wildfly-jpa- org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java.security.AccessController.doPrivileged(Native Method)[rt.jar:1.8.0_60]的8.2.0.Final.jar:8.2.0.Final]。 java:474)[wildfly-s ecurity-manager-1.0.0.Final.jar:1.0.0.Final] at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_60] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_60] at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_60] at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final] Caused by: org.hibernate.HibernateException: Missing table: POI_SERVICE at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1335) [hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155) [hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:525) [hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibern ecurity-manager-1.0.0.Final.jar:1.0.0.Final]位于org.jboss.as.jpa.service.PersistenceUnitServiceImpl $ 1.run(PersistenceUnitServiceImpl.java:182)[wildfly-jpa-8.2.0.Final .jar:8.2.0.Final] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[rt.jar:1.8.0_60] at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor。 java:617)[rt.jar:1.8.0_60] at java.lang.Thread.run(Thread.java:745)[rt.jar:1.8.0_60] at org.jboss.threads.JBossThread.run(JBossThread。 java:122)[jboss-threads-2.1.1.Final.jar:2.1.1.Final]原因:org.hibernate.HibernateException:缺少表:org.hibernate.cfg.Configuration.validateSchema(Configuration.java :1335)[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)[hibernate-core-4.3.7。 org.hibernate.internal.SessionFactoryImpl。(SessionFactoryImpl.java:525)的Final.jar:4.3.7.Final](org.hibern的[hibernate-core-4.3.7.Final.jar:4.3.7.Final] ate.cfg.Configuration.buildSessionFactory(Configuration.java:1859) [hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) [hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final] at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) [jipijapa-hibernate4-3-1.0.1.Final.jar:] at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitS ate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)[hibernate-core-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl $ 4.perform(EntityManagerFactoryBuilderImpl .java:852)[hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl $ 4.perform(EntityManagerFactoryBuilderImpl.java:845)[hibernate-entitymanager -4.3.7.Final.jar:4.3.7.Final]位于org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)[hibernate-core-4.3.7.Final.jar :4.3.7.Final],位于org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844)[hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final],位于org。 jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)[jipijapa-hibernate4-3-1.0.1.Final.jar:]在org.jboss.as.jpa.service.PersistenceUnitServiceImpl $ 1 $ 1.run (PersistenceUnitS erviceImpl.java:154) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final] ... 8 more erviceImpl.java:154)[wildfly-jpa-8.2.0.Final.jar:8.2.0.Final] ...还有8个

2016-01-08 12:24:58,786 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000261: Table found: POIOPS.POI_SERVICE 2016-01-08 12:24:58,788 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000037: Columns: [last_record, application, last_update, id, last_date] 2016-01-08 12:25:00,774 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000261: Table found: POIOPS.IDENTIFICATION_REQUEST 2016-01-08 12:25:00,775 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000037: Columns: [sworkstationid, yafp2wsqimage, stransactiontime, created, stype, bretphoto, scardseqno, stranid, breturnname, smode, requesttype, ssiteid, identificationresponse_id, sidn, id, yafp1wsqimage, updated, ifpind1, ifpind2] 2016-01-08 12:25:05,385 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000261: Table found: POIOPS.IDENTIFICATION_RESPONSE 2016 2016-01-08 12:24:58,786 INFO [org.hibernate.tool.hbm2ddl.TableMetadata](ServerService线程池-57)HHH000261:找到的表:POIOPS.POI_SERVICE 2016-01-08 12:24:58,788 INFO [ org.hibernate.tool.hbm2ddl.TableMetadata](ServerService线程池-57)HHH000037:列:[last_record,应用程序,last_update,id,last_date] 2016-01-08 12:25:00,774 INFO [org.hibernate.tool .hbm2ddl.TableMetadata](ServerService线程池-57)HHH000261:找到的表:POIOPS.IDENTIFICATION_REQUEST 2016-01-08 12:25:00,775 INFO [org.hibernate.tool.hbm2ddl.TableMetadata](ServerService线程池-57 )HHH000037:列:[sworkstationid,yafp2wsqimage,stransactiontime,已创建,stype,bretphoto,scardseqno,stranid,breturnname,smode,requesttype,ssiteid,identificationresponse_id,sidn,id,yafp1wsqimage,2016年08月,ifpind1 :25:05,385信息[org.hibernate.tool.hbm2ddl.TableMetadata](ServerService线程池-57)HHH000261:找到的表:POIOPS.IDENTIFICATION_RESPONSE 2016 -01-08 12:25:05,387 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000037: Columns: [bnameret, created, sfpind2, scallcentreno, ifp2score, stranid, sidissuedate, ierror, ifp1score, sfp1result, sidn, sname, serror, sfp2result, sfpind1, yaphoto, ssmartcardind, id, ssurname, updated] 2016-01-08 12:25:09,367 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000261: Table found: POIOPS.IDENTIFICATIONREQUEST 2016-01-08 12:25:09,369 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000037: Columns: [sworkstationid, responseerror, yafp2wsqimage, stransactiontime, created, stype, bretphoto, scardseqno, stranid, breturnname, smode, requesttype, ssiteid, sidn, id, yafp1wsqimage, updated, ifpind1, ifpind2] 2016-01-08 12:25:15,851 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000261: Table found: POIOPS.IDENTIFICATIONRESPONSE 2016-01-08 12:25:15,853 INFO -01-08 12:25:05,387 INFO [org.hibernate.tool.hbm2ddl.TableMetadata](ServerService线程池-57)HHH000037:列:[bnameret,创建,sfpind2,scallcentreno,ifp2score,stranid,sidissuedate,ierror, ifp1score,sfp1result,sidn,sname,serror,sfp2result,sfpind1,yaphoto,ssmartcardind,id,ssurname,更新] 2016-01-08 12:25:09,367 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] -57)HHH000261:找到表:POIOPS.IDENTIFICATIONREQUEST 2016-01-08 12:25:09,369信息[org.hibernate.tool.hbm2ddl.TableMetadata](ServerService线程池-57)HHH000037:列:[sworkstationid,responseerror ,yafp2wsqimage,stransactiontime,创建,stype,bretphoto,scardseqno,stranid,breturnname,smode,requesttype,ssiteid,sidn,id,yafp1wsqimage,更新,ifpind1,ifpind2] 2016-01-08 12:25:15,851信息[org.hibernate .tool.hbm2ddl.TableMetadata](ServerService线程池-57)HHH000261:找到的表:POIOPS.IDENTIFICATIONRESPONSE 2016-01-08 12:25:15,853信息 [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 57) HHH000037: Columns: [bnameret, created, sfpind2, scallcentreno, ifp2score, stranid, sidissuedate, ierror, ifp1score, sfp1result, sidn, sname, serror, sfp2result, sfpind1, yaphoto, ssmartcardind, id, ssurname, updated, request_id] 2016-01-08 12:25:15,994 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "poiextractor-ear-1.0.0-SNAPSHOT.ear")]) - failure description: {"JBAS014671: Failed services" => {"jboss.persistenceunit.\\"poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit\\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\\"poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit\\": org.hibernate.HibernateException: Missing table: POI_SERVICE Caused by: org.hibernate.HibernateException: Missing table: POI_SERVICE"}} 2016-01-08 12:25:15,996 ERROR [org.jboss.as.server] (manageme [org.hibernate.tool.hbm2ddl.TableMetadata](ServerService线程池-57)HHH000037:列:[bnameret,创建的,sfpind2,scallcentreno,ifp2score,stranid,sidissuedate,ierror,ifp1score,sfp1error,sid,sid sfp2result,sfpind1,yaphoto,ssmartcardind,id,ssurname,更新,request_id] 2016-01-08 12:25:15,994错误[org.jboss.as.controller.management-operation](management-handler-thread-2)JBAS014613 :操作(“ deployment”)失败-地址:([(“ deployment” =>“ poiextractor-ear-1.0.0-SNAPSHOT.ear”)])-失败描述:{“ JBAS014671:失败的服务” => {“ jboss.persistenceunit。\\“ poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit \\”“ =>”服务jboss.persistenceunit中的org.jboss.msc.service.StartException。\\“ poiextractor-ear-1.0.0- SNAPSHOT.ear#POIPersistenceUnit \\“:org.hibernate.HibernateException:缺少表:POI_SERVICE原因:org.hibernate.HibernateException:缺少表:POI_SERVICE”}}} 2016-01-08 12:25:15,996错误[org.jboss。 as.server](管理 nt-handler-thread - 2) JBAS015870: Deploy of deployment "poiextractor-ear-1.0.0-SNAPSHOT.ear" was rolled back with the following failure message: {"JBAS014671: Failed services" => {"jboss.persistenceunit.\\"poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit\\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\\"poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit\\": org.hibernate.HibernateException: Missing table: POI_SERVICE Caused by: org.hibernate.HibernateException: Missing table: POI_SERVICE"}} 2016-01-08 12:25:15,997 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) JBAS010418: Stopped Driver service with driver-name = poiextractor-ear-1.0.0-SNAPSHOT.ear_org.h2.Driver_1_4 2016-01-08 12:25:15,998 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 57) JBAS011410: Stopping Persistence Unit (phase 2 of 2) Service 'poiextractor-ear-1.0.0-SNAPSHOT.ear#POIExtractorPersistenceUnit' 2016-01-08 12:25:16,018 INFO [org.jboss.weld.deployer] nt-handler-thread-2)JBAS015870:部署部署“ poiextractor-ear-1.0.0-SNAPSHOT.ear”已回滚,并显示以下失败消息:{“ JBAS014671:服务失败” => {“ jboss.persistenceunit。 \\“ poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit \\”“ =>”服务jboss.persistenceunit中的org.jboss.msc.service.StartException。\\“ poiextractor-ear-1.0.0-SNAPSHOT.ear# POIPersistenceUnit \\“:org.hibernate.HibernateException:缺少表:POI_SERVICE原因:org.hibernate.HibernateException:丢失表:POI_SERVICE”}}} 2016-01-08 12:25:15,997 INFO [org.jboss.as.connector。 deployers.jdbc](MSC服务线程1-6)JBAS010418:已停止的驱动程序服务,其驱动程序名称= poiextractor-ear-1.0.0-SNAPSHOT.ear_org.h2.Driver_1_4 2016-01-08 12:25:15,998 INFO [org [jboss.as.jpa](ServerService线程池-57)JBAS011410:正在停止持久性单元(第2阶段,共2阶段)服务'poiextractor-ear-1.0.0-SNAPSHOT.ear#POIExtractorPersistenceUnit'2016-01-08 12:25 :16,018信息[org.jboss.weld.deployer] (MSC service thread 1-9) JBAS016009: Stopping weld service for deployment poiextractor-ear-1.0.0-SNAPSHOT.ear 2016-01-08 12:25:16,043 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 57) JBAS011410: Stopping Persistence Unit (phase 1 of 2) Service 'poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit' 2016-01-08 12:25:16,043 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 59) JBAS011410: Stopping Persistence Unit (phase 1 of 2) Service 'poiextractor-ear-1.0.0-SNAPSHOT.ear#POIExtractorPersistenceUnit' (MSC服务线程1-9)JBAS016009:停止用于部署poiextractor-ear-1.0.0-SNAPSHOT.ear的焊接服务2016-01-08 12:25:16,043信息[org.jboss.as.jpa](ServerService线程池-57)JBAS011410:正在停止持久性单元(第1阶段,共2阶段)服务'poiextractor-ear-1.0.0-SNAPSHOT.ear#POIPersistenceUnit'2016-01-08 12:25:16,043 INFO [org.jboss.as.jpa ](ServerService线程池-59)JBAS011410:停止持久性单元(第1阶段,共2阶段)服务'poiextractor-ear-1.0.0-SNAPSHOT.ear#POIExtractorPersistenceUnit'

UPDATE 2: When I remove this property from the persistence.xml everything works fine. 更新2:当我从persistence.xml中删除此属性时,一切正常。

<property name="hibernate.hbm2ddl.auto" value="validate" />

A JPA EntityManager belongs to one persistence unit, or EntityManagerFactory , You can't mix multiple persistence units with the same EntityManager . 一个JPA EntityManager属于一个持久性单元或EntityManagerFactory ,您不能将多个持久性单元与同一EntityManager混合使用。

But you don't have to do that. 但是您不必这样做。

You can have a single persistence unit and use the schema attribute when mapping entities. 您可以有一个持久性单元,并在映射实体时使用schema属性。

If you use multiple persistence units, you need multiple persistence.xml , multiple EntityManagerFactory and probably JTA if you need to global transactions. 如果使用多个持久性单元,则需要多个persistence.xml ,多个EntityManagerFactory ,如果需要全局事务,则可能需要JTA。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM