openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Abe White (JIRA)" <>
Subject [jira] Commented: (OPENJPA-119) EntityManager.clear() should not implicitly invoke the flush operation
Date Mon, 05 Feb 2007 03:58:05 GMT


Abe White commented on OPENJPA-119:

I'm not saying we need to add the new detachAll method, but I don't understand everyone's
fear of breaking anything by adding new public methods.  It's very hard to break anything
by adding a new public method.  The only thing you can possibly break is a non-dynamic proxy
that implements the interface (OpenJPAEntityManager) without extending the impl (EntityManagerImpl).
 Anyone layering on top of OpenJPA in that fashion has to realize that their implementation
will need updating fairly often.

> EntityManager.clear() should not implicitly invoke the flush operation
> ----------------------------------------------------------------------
>                 Key: OPENJPA-119
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>            Reporter: Kevin Sutter
>         Assigned To: Kevin Sutter
> From the dev mailing list... 
> ======================================= 
> We've noticed that when EntityManager.clear() is invoked, an implicit flush() is performed.
Although the spec is cloudy in this area, I don't think this processing is correct. The javadoc
is as follows for clear(): 
> /** 
> * Clear the persistence context, causing all managed 
> * entities to become detached. Changes made to entities that 
> * have not been flushed to the database will not be 
> * persisted. 
> */ 
> public void clear(); 
> This indicates that Entities that have not been flushed will not be persisted. Thus,
I would say this implies that we should not be doing an implicit flush. If the application
wanted their Entities to be flushed before the clear, then they can call the flush() method
before calling clear(). We shouldn't be doing this for them because then they have no choice.

> The Pro EJB3 Java Persistence API book has similar wording on pages 138-139: 
> "..In many respects [clear] is semantically equivalent to a transaction rollback. All
entity instances managed by the persistence context become detached with their state left
exactly as it was when the clear() operation was invoked..." 
> Our current processing for clear() eventually gets to this code: 
> public void detachAll(OpCallbacks call) { 
> beginOperation(true); 
> try { 
> if ((_flags & FLAG_FLUSH_REQUIRED) != 0) 
> flush(); 
> detachAllInternal(call); 
> } catch (OpenJPAException ke) { 
> throw ke; 
> } catch (RuntimeException re) { 
> throw new GeneralException(re); 
> } finally { 
> endOperation(); 
> } 
> } 
> Basically, if we have dirtied the Persistence Context, then do a flush() followed by
the detachAllInternal(). I don't think the clear() should be doing this flush() operation.
Any disagreement? 
> ======================================= 
> There was no disagreement, thus this JIRA issue.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message