Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] synchronization of new object question

The issues is that by default in JPA execution of a Query causes the
EntityManager to be flushed.  The flushing is detecting a new object that
has not been persisted, and is in a non-cascade persist relationship.

You can configure the flushMode on an EntityManager to only flush on commit. 
But to avoid the same error on commit you need to either persist the new
object, or configure the relationship to it to cascade persist.


Leon Derks-2 wrote:
> 
> I get the error message below when I run the following:
> 
> getEntityManager().createNamedQuery("findImageInfoByExample").setParameter("visualElementId", 
> visualElementId).getSingleResult();
> 
> My question is, why is the entitymanager synchronizing during this 
> query? I would expect to synchronize only during entityManager.persist() 
> or merge().
> 
> I don't want to persist the new , but want to check if the same is 
> already stored in the db.
> 
> Is it possible to disable the synchronisation?
> 
> Error:
> During synchronization a new object was found through a relationship 
> that was not marked cascade PERSIST: ****.model.
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/synchronization-of-new-object-question-tp17776160p17778129.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top