openjpa-dev mailing list archives

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

> On Fri, Aug 28, 2009 at 11:40 AM, Daryl Stultz <daryl@6degrees.com> 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.close();
em = getEntityManager();
B b = em.find(B.class, 2);
em.close();
em = getEntityManager();
a.setB(b); // presuming this is a different B value than before
em.merge(a);

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

EntityManager em = getEntityManager();
B b = em.find(B.class, 2);
em.close();
em = getEntityManager();
A a = new A();
a.setB(b);
em.persist(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.
http://www.6degrees.com
mailto:daryl@6degrees.com

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