Yes, the usage is the common usage pattern,
entity = em.merge(entity)
I've seen this behavior a number of times now. Does this have
something to do with a "Detached State" setting and OpenJPA
enhancement, which I saw something about in an earlier discussion on
this list but did not understand?
-Marc
On Nov 28, 2007 4:12 PM, Oliver Zeigermann <[EMAIL PROTECTED]> wrote:
> Are you very sure that after a merge you work on the copy returned by merge?
>
> Oliver
>
>
> 2007/11/28, Marc Siegel <[EMAIL PROTECTED]>:
> > Detached, let's say from a em.find() call in an earlier transaction.
> >
> > -Marc
> >
> > On Nov 28, 2007 7:38 AM, Oliver Zeigermann <[EMAIL PROTECTED]> wrote:
> > > Where does the old enity come from?
> > >
> > > 2007/11/28, Marc Siegel <[EMAIL PROTECTED]>:
> > >
> > > > Hi folks,
> > > >
> > > > I've had to replace a number of lines of this sort:
> > > >
> > > > em.getTransaction().begin();
> > > > entity = em.merge(entity); // <==
> > > > entity.setSomething(value)
> > > > em.getTransaction().commit();
> > > >
> > > > With lines of this sort:
> > > >
> > > > ...
> > > > entity = em.find(entity.getClass(), entity.getId()); // <==
> > > > ...
> > > >
> > > >
> > > > Otherwise, the set field does not get written out, although all
> > > > requests to the current EntityManager will return the new values. But
> > > > if you call em.close(), and create a new EntityManager, the requests
> > > > will still show the old value.
> > > >
> > > > Can someone with insight into the code please explain?
> > > >
> > > > Thanks
> > > > -Marc
> > > >
> > >
> >
>