tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: em.clear() in a non transactional context
Date Wed, 11 Feb 2009 05:06:02 GMT

On Feb 2, 2009, at 9:07 AM, Jean-Sébastien Scrève wrote:

> I have a question regarding the em.clear() in the JtaEntityManager  
> class.
> Before clearing the context, OpenEJB checks that a transaction is  
> currently
> active.
> Is there any reason for that ? I don't see any mention of this  
> behavior in
> the specification.

It has to do with the lifecycle of a  
PersistenceContextType.TRANSACTION EntityManager.  The long and short  
of it is that the JtaEntityManager will create an EntityManager  
(PersistenceContext) at the beginning of a transaction and destroy it  
at the end of the transaction.  So when no transaction is active,  
there is no EntityManager to call clear() on and no PersistenceContext  
data to clear.


View raw message