openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marc Siegel" <marc.siegel...@gmail.com>
Subject Re: Why do I sometimes need to call em.find instead of em.merge
Date Wed, 28 Nov 2007 15:55:13 GMT
Detached, let's say from a em.find() call in an earlier transaction.

-Marc

On Nov 28, 2007 7:38 AM, Oliver Zeigermann <oliver@zeigermann.de> wrote:
> Where does the old enity come from?
>
> 2007/11/28, Marc Siegel <marc.siegel.17@gmail.com>:
>
> > 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
> >
>

Mime
View raw message