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

Hi James,

Thanks, that is the answer I was looking for.

James Sutherland wrote:
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?

During synchronization a new object was found through a relationship that was not marked cascade PERSIST: ****.model.

--- James Sutherland
 EclipseLink ,
TopLink Wiki: EclipseLink , TopLink Forums: TopLink , EclipseLink Book: Java Persistence

Back to the top