[jboss-jira] [JBoss JIRA] (WFLY-9516) JPA deployer adding cross sub deployment dependencies when multiple persistence units deployed
Scott Marlow (JIRA)
issues at jboss.org
Mon Aug 13 09:57:00 EDT 2018
[ https://issues.jboss.org/browse/WFLY-9516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13618248#comment-13618248 ]
Scott Marlow commented on WFLY-9516:
------------------------------------
>From a JPA standard point of view, JPA 2.2 specification section 8.2.2 states that the scope of a persistence unit in a sub-deployment, is defined with in the jar or war and only visible to components defined in the jar or war.
{code}
8.2.2 Persistence Unit Scope
An EJB-JAR, WAR, application client jar, or EAR can define a persistence unit.
When referencing a persistence unit using the unitName annotation element or persistence-unit-name deployment descriptor element, the visibility scope of the persistence unit is determined by its point of definition:
• A persistence unit that is defined at the level of an EJB-JAR, WAR, or application client jar is scoped to that EJB-JAR, WAR, or application jar respectively and is visible to the components defined in that jar or war.
• A persistence unit that is defined at the level of the EAR is generally visible to all components in the application. However, if a persistence unit of the same name is defined by an EJB-JAR, WAR, or application jar file within the EAR, the persistence unit of that name defined at EAR level will not be visible to the components defined by that EJB-JAR, WAR, or application jar file unless the persistence unit reference uses the persistence unit name # syntax to specify a path name to disambiguate the reference. When the # syntax is used, the path name is relative to the referencing application component jar file. For example, the syntax ../lib/persistenceUnitRoot.jar#myPersistenceUnit refers to a persistence unit whose name, as specified in the name element of the persistence.xml file, is myPersistenceUnit and for which the relative path name of the root of the persistence unit is ../lib/persistenceUnitRoot.jar. The # syntax may be used with both the unitName annotation element or persistence-unit-name deployment descriptor element to reference a persistence unit defined at EAR level.
{code}
Perhaps an option #3 solution, could be an extension, that if enabled, would scan sub-deployments for @PersistenceUnit/PersistenceContext references to other sub-deployments persistence units, such that sub-deployment1 could depend on a persistence unit in sub-deployment2, as long as sub-deployment2 doesn't depend on a persistence unit in sub-deployment1. I'm not sure if this would work but it could be attempted at some point.
> JPA deployer adding cross sub deployment dependencies when multiple persistence units deployed
> ----------------------------------------------------------------------------------------------
>
> Key: WFLY-9516
> URL: https://issues.jboss.org/browse/WFLY-9516
> Project: WildFly
> Issue Type: Bug
> Components: JPA / Hibernate
> Affects Versions: 11.0.0.Final
> Reporter: Brad Maxwell
> Assignee: Scott Marlow
>
> If an ear contains two EJB sub deployments which each contain a Persistence Unit and a Stateless EJB which injects the PU that is in its jar using @PersistenceContext. There is a dependency being added where in the Stateless EJB from one deployment depends on the PU from the other jar. It appears this is happening after this bug fix WFLY-1531
> {code}
> app.ear
> - ejb-with-pu1.jar
> - ejb-with-pu2.jar
> {code}
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
More information about the jboss-jira
mailing list