[JPA_SPEC-83] Require lazy registeration of entity listeners after createContainerEntityManagerFactory() call Created: 10/Jul/14  Updated: 22/Jul/16

Status: Open
Project: jpa-spec
Component/s: None
Affects Version/s: None
Fix Version/s: 2.2

Type: Improvement Priority: Major
Reporter: smarlow Assignee: ldemichiel
Resolution: Unresolved Votes: 6
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


https://java.net/projects/jpa-spec/lists/jsr338-experts/archive/2014-01/message/3 didn't get much feedback but https://issues.jboss.org/browse/WFLY-2387 has gotten interest. The issue is that CDI injection allows you to inject the persistence context, and listeners support CDI injection, which may need the same persistence unit (causing a cycle). One way to resolve the cycle, is to ensure that persistence units always are available before the entity listeners are registered.

Add a requirement that entity listeners are registered after the EntityManagerFactory is created (after createContainerEntityManagerFactory(PersistenceUnitInfo, Map) returns) and before it is needed by the application.

Comment by smarlow [ 18/Jul/16 ]

Revised suggested requirement change, to allow entity listener to be registered any time after EntityManagerFactory is available, as long as the entity listener is registered before it is needed. This allows the entity listener to be registered on first use or any time after the createContainerEntityManagerFactory() call returns.

Comment by smarlow [ 22/Jul/16 ]

I think that we need to clarify how soon the entity listener can be registered. Just after the createContainerEntityManagerFactory() might be too soon. It might need to be after the javax.enterprise.inject.spi.AfterDeploymentValidation has triggered.

Generated at Sun Jul 24 20:37:20 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.