It was a sample that describes a problem. 
I get an 10 level deep object graph with circular references from WS 
(unmarshalled from xml).
I need to merge it with my database.

Some object in the graph already presents in my database. Some is new. 

-----Original Message-----
From: "Michael Dick" <[EMAIL PROTECTED]>
To: [email protected], "Luc1fer Hell" <[EMAIL PROTECTED]>
Date: Mon, 19 Nov 2007 11:27:41 -0600
Subject: Re: Merge not working as SaveOrUpdate

> 
> I think the problem here is that you're creating a new RRole Entity instead
> of updating a detached Entity. When you call em.merge() on a new entity it
> operates in the same manner as em.persist(). One way to resolve the problem
> is to make sure you're dealing with a detached or managed copy of the entity
> before calling merge().
> 
> Something like this might work.
> 
>  RRole role = new RRole(99999l, "dasf", "df");
>  rroleService.add(role);
> 
> // I'm assuming some other work takes place here
> // If you still have access to the original role then
> // you can omit the em.find() call below.
> 
> role = em.find(RRole.class, 99999l);
> 
> role.setString1 ("dasffsdf");
> rroleService.update(role);
> 
> Where update:
>  RRole mergedEntity = em.merge(entity);
> 
> Hope this helps,
> -Mike
> 
> On Nov 19, 2007 4:41 AM, Luc1fer Hell <[EMAIL PROTECTED]> wrote:
> 
> > A have to add, that i don't use generated annotation on id's.
> > And exception throws on merge, it doesn't execute persist.
> >
> >
> 
> 

Reply via email to