users@jpa-spec.java.net

[jpa-spec users] [jsr338-experts] Re: changes for 7.6.2 Container-managed Transaction-scoped Persistence Context

From: Scott Marlow <smarlow_at_redhat.com>
Date: Sat, 26 Nov 2011 12:03:59 -0500

Update to the last paragraph in 7.6.2:

"
If the entity manager is invoked outside the scope of a transaction, any
entities loaded from the database will immediately become detached at
the end of the container method invocation (persistence context will
also end).
"

Or another way to state this could be:

"
If the entity manager is invoked outside the scope of a transaction, the
persistence context will end when the container level invocation
completes. In which case, any entities loaded from the database will
immediately become detached.
"

On 11/25/2011 02:20 PM, Scott Marlow wrote:
> On 11/25/2011 11:09 AM, Scott Marlow wrote:
>> Could we change 7.6.2 Container-managed Transaction-scoped Persistence
>> Context to be more clear in the following paragraph:
>>
>> "
>> If the entity manager is invoked outside the scope of a transaction, any
>> entities loaded from the database will immediately become detached at
>> the end of the method call.
>> "
>>
>> Which method call do we mean exactly? I think we mean each entity
>> manager call (e.g. EntityManager.find). Perhaps changing to:
>>
>> "
>> If the entity manager is invoked outside the scope of a transaction, any
>> entities loaded from the database will immediately become detached at
>> the end of the entity manager method call.
>> "
>
> I probably have interpreted the wording incorrectly, I think it should
> be at the end of the container level method invocation. All the more
> reason to be explicit with the wording. ;)
>
>>
>> Which rules out other possible interpretations of which method is
>> referred to.
>>
>> Related to this, could the previous paragraph:
>>
>> "
>> The persistence context ends when the associated JTA transaction commits
>> or rolls back, and all entities that were managed by the EntityManager
>> become detached.[80]
>> "
>>
>> Also be made more specific about when the persistence context ends for
>> the transaction scoped entity manager that is invoked outside of a JTA
>> transaction. Detaching the loaded entities is different than closing the
>> persistence context.
>>
>> Perhaps we could cover this with an additional change to the last
>> paragraph in this section:
>>
>> "
>> If the entity manager is invoked outside the scope of a transaction, any
>> entities loaded from the database will immediately become detached at
>> the end of the entity manager method call. The persistence context may
>> end after each entity manager method call (some implementations could
>> release the persistence context at the end of the container invocation).
>> "
>>
>> Scott
>