Do you have a version field configured? It sounds like OpenJPA thinks that your instances are new, not detached. This can happen if you use a version field but are not setting it, or if the id field is not set in the data model.
I think that it can also happen if you're running the enhancer on your types and using the default DetachState settings; in this case, I think that OpenJPA assumes that when your classes are reattached, they will have an internally-generated extra field identifying them as such. Can you post your persistence.xml file? -Patrick On Nov 20, 2007 12:03 AM, Luc1fer Hell <[EMAIL PROTECTED]> wrote: > > 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. > > > > > > > > > > > -- Patrick Linskey 202 669 5907
