Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Big problem: QueryException in simple JPA Case

The difference between TopLink Essentials is that TopLink Essentials just did
a find() for getReference() where as EclipseLink returns an un-fetched
object.  If you switch to using a find() or disable fetch group weaving
("eclipselink.weaving.fetchgroups"="false"), this should resolve the issue.

But, I'm not sure why you are getting the issue.  Can you try the latest
release, if you still get the error please log a bug and include your test

bht wrote:
> Hi,
> JPA fails when I access properties of detached objects. This happens
> when the persistence context is new, that means that the objects were
> not used before except by the first call to
> EntityManager.getReference() that gets them before they leave the
> persistence context.
> The exception is not thrown with TopLink Essentials. Details of the
> exception are below.
> I am fully aware that the objects are detached, and that lazily
> fetched related objects or properties may not be available in the
> detached state. So I fetch and set all related objects in the session
> using EntityManager.getReference() so the object graph is complete
> when it leaves the transaction.
> A possible workaround is to "touch" i.e. get the properties that are
> subject to the crashes within the session/transaction. Example:
> parentEntity.getChildEntity().getName();
> However this workaround is not feasible because it means that I would
> have to load the whole database into memory and touch all properties
> before it is usable.
> I have searched the web for any ideas what I might be missing in the
> configuration.
> I can reproduce this error in a testcase with JVM setting
> -javaagent:eclipselink-2.0.0.jar, and I am getting this problem with
> GlassFish V3.0 out of the box.
> Any help or hints are highly appreciated.
> Many thanks in advance!
> Bernard
> Details of the exception:
> Exception [EclipseLink-6004] (Eclipse Persistence Services -
> 2.0.0.v20091127-r5931):
> org.eclipse.persistence.exceptions.QueryException
> Exception Description: The object [...], of class [class ...], with
> identity hashcode (System.identityHashCode()) [...], 
> is not from this UnitOfWork object space, but the parent session's.
> The object was never registered in this UnitOfWork, 
> but read from the parent session and related to an object registered
> in the UnitOfWork.  Ensure that you are correctly
> registering your objects.  If you are still having problems, you can
> use the UnitOfWork.validateObjectSpace() method to 
> help debug where the error occurred.  For more information, see the
> manual or FAQ.
> Query: ReadObjectQuery(referenceClass=... sql="SELECT ID, .., ... FROM
> ... WHERE (ID = ?)")
>         at
> org.eclipse.persistence.exceptions.QueryException.backupCloneIsOriginalFromParent(

----- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top