[jpa-spec users] [jsr338-experts] timing of when entity listeners are registered...

From: Scott Marlow <>
Date: Thu, 23 Jan 2014 09:19:51 -0500


I would like feedback on when entity listeners should be registered
(during application deployment when
PersistenceProvider.createContainerEntityManagerFactory() is called or
later when the entity listener is about to be called for the first time). brings up a use case, where an
entity listener
references an entity manager.

Whether its a self-reference, from creating the initial
EntityManagerFactory, that references the entity listener, which in turn
has a self reference back to the same persistence unit. Or, the entity
listener references a different persistence unit. I don't think we have
described this case as a JPA requirement. However, its not unreasonable
that some applications might try to do this.

Should we make it a (JPA) requirement that persistence providers defer
registering the entity listener until the application needs to call one
of the listener events?

What do you think about allowing persistence providers to register
entity listeners as late as on first application use?

In the interest of standards, I would like to nail down whether we want
to leave the requirements *open* in the future or agree on intent of
what we want to do in the next spec release for this case.