users@jpa-spec.java.net

[jpa-spec users] Is it allowed for SFSB to return extended EntityManager to clients?

From: <donatas.ciuksys_at_mif.vu.lt>
Date: Tue, 29 Jan 2013 09:56:16 +0000 (GMT)

Dear JPA experts,

Could you please clarify, whether it is allowed for stateful session
bean having container-managed extended persistence context to return

its EntityManager to clients (and for clients to perform operations on
this EntityManager), or is it forbidden?

Currently, GlassFish allows returning the extended EntityManager to
outside (e.g. http://java.net/jira/browse/GLASSFISH-11805), Apache
OpenEJB does not, and there is currently ongoing discussion about issue
https://issues.apache.org/jira/browse/TOMEE-509 .

JPA 2.0 specification had following text (stars added by me):

-----------------------------------------------
3.3 Persistence Context Lifetime
...
When an extended persistence context is used, the extended persistence
context exists from the time the
EntityManager instance is created until it is closed. This persistence
context might span multiple transactions
and non-transactional invocations of the EntityManager. A
container-managed extended persistence
context is enlisted in the current transaction when *the EntityManager
is invoked in the scope of
that transaction* or when the stateful session bean to which the
extended persistence context is bound is
invoked in the scope of that transaction.
-----------------------------------------------

The part between “*” seems to suggest, that EntityManager could be
accessed by some external entity directly, not necessarily through

stateful session bean method.
I cannot find this text in JPA 2.1 public draft though.
 
Question: can reference to extended EntityManager be provided to
outside, and methods called on this reference?

Regards,
Donatas