persistence@glassfish.java.net

Accessing Properties of detached POJOs with GlassFish V3 and EclipseLink 2.0

From: <bht_at_actrix.gen.nz>
Date: Fri, 19 Feb 2010 19:53:45 +1300

Hi,

I am very happy with GlassFish V2 and TopLink Essentials. Now I need
to move on to GlassFish V3 and EclipseLink JPA 2.0.

But I am overwhelmed with a new EclipseLink 2.0 behavior that is not
compatible with my web application, and not compatible with the
behavior of TopLink Essentials. The problem I am facing is just TOO
BIG!

In a typical case, the web tier accesses detached entities as POJOs
that are provided by session beans within the same VM.

With such simple data access, EclipseLink 2.0 throws:

Exception Description: The object [entity...], of class [class ...],
with identity hashcode (System.identityHashCode()) [...],
is not from this UnitOfWork object space, but the parent session's.

- on access of properties of entities that the session bean
successfully fetched via EntityManager.getReference()!

Of course there is no UnitOfWork in the scope of the web application,
and the object should simply behave like a POJO. That's the point of
EJB 3 as I understand it.

I would appreciate very much if someone could provide me with ideas on
how to avoid this issue. I have filed a report with a comprehensive
testcase at:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=303041

Many thanks in advance!

Bernard