On Fri, Sep 4, 2009 at 8:59 AM, Daryl Stultz <[email protected]> wrote:

Can I get someone to comment on this?


> 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.
>
> Thanks.

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[email protected]

Reply via email to