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

Reply via email to