Wildfly中有多个持久性单元? [英] Multiple persistence units in Wildfly?

查看:149
本文介绍了Wildfly中有多个持久性单元?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Wildfly(9.0.2)应用程序中是否可以有两个持久性单元?

Is it possible to have two persistence units in a Wildfly (9.0.2) application?

我得到"WFLYJPA0061:未指定持久性单元名称,并且在应用程序部署部署"jasper-web.war"中有2个持久性单元定义.要么更改应用程序部署,使其仅具有一个持久性单元定义,要么为每个持久性单元指定unitName引用一个持久性单元."

I get "WFLYJPA0061: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment deployment "jasper-web.war". Either change the application deployment to have only one persistence unit definition or specify the unitName for each reference to a persistence unit."

我在@PeristenceContext批注中指定了unitName.我在某个可以禁用的地方读书

I have unitName specified in the @PeristenceContext annotations. I read somewhere I could disable

<!--
<subsystem xmlns="urn:jboss:domain:jpa:1.1">
    <jpa default-datasource="" default-extended-persistence-inheritance="DEEP"/>
</subsystem>
-->

中的

.这消除了错误消息,但也禁用了对objectManagers的注入(在代码中引用它们的空指针)

in standalone.xml. This removed the error message, but also disabled injection of entityManagers (null pointer referencing them in code)

我试图将持久性单元划分为两个不同的ejb-jar,每个都有各自的persistence.xml,但是由于它们仍包含在同一场战争中,因此Wildfly仍然抱怨.

I have tried to split the persistence units over two different ejb-jars, each with their own persistence.xml, but as they're still included in the same war, Wildfly still complains.

这两个持久单元与休眠一起使用,一个与postgresql数据库一起使用,另一个与用于ms访问的ucanaccess驱动程序一起使用.他们俩都是分开工作的.

The the two persistence units are used with hibernate, one with a postgresql database and one with a ucanaccess driver for ms access. They both work separately.

推荐答案

正如约翰·阿门特(John Ament)指出的那样,错误消息实际上指示了没有unitName的注入点(在源代码中我已经忘记了……)摆脱了这一点,一切都按预期进行.当我实际上在jboss AS中发现一些旧问题时,我对此感到有些困惑,这实际上曾经是一个问题.

As John Ament pointed out the error message actually indicates an injection point without unitName (that I had forgotten about in my source...) As soon as I got rid of that, everything worked as it should. I also got a bit confused googling this problem, when I actually found some old issues in jboss AS where this actually seems to have been a problem, once.

这篇关于Wildfly中有多个持久性单元?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆