openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <>
Subject Re: SingleFieldManager.preFlushPC
Date Fri, 04 Sep 2009 12:59:22 GMT
On Fri, Aug 28, 2009 at 1:35 PM, Michael Dick <>wrote:

> On Fri, Aug 28, 2009 at 11:40 AM, Daryl Stultz <> wrote:
> > Does this mean an object that has *never* been associated with an em, or
> > one
> > that is not *currently* associated? Are you referring only to "new"
> > objects?
> > Is a detached instance "unmanaged"?
> >
> Both Entities that have never been associated with an EM and those which
> are
> not  currently associated with an EM are considered unmanaged.
> Put another way unmanaged == OpenJPA is not tracking the changes you make
> to
> the entity. So new entities and detached entities are unmanaged.
> I thought changes were tracked if the instance has a state manager. Is a
detached entity with a state manager considered unmanaged?

Does this look like it should work or fail:

EntityManager em = getEntityManager();
A a = em.find(A.class, 1);
em = getEntityManager();
B b = em.find(B.class, 2);
em = getEntityManager();
a.setB(b); // presuming this is a different B value than before

The property "b" on "a" is not set to Cascade. How about this:

EntityManager em = getEntityManager();
B b = em.find(B.class, 2);
em = getEntityManager();
A a = new A();

This is the general idea to what I'm doing, though the object graph is a bit
more complicated. I'm still trying to understand what state "b" is expected
to be in if I'm not using CascadeType.PERSIST/MERGE.

Daryl Stultz
6 Degrees Software and Consulting, Inc.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message