openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pawel Veselov <pawel.vese...@gmail.com>
Subject Re: temporary entity left in the database after being deleted.
Date Fri, 30 Dec 2011 09:13:28 GMT
Hi Rick.

On Thu, Dec 29, 2011 at 4:45 AM, Rick Curtis <curtisr7@gmail.com> wrote:

> Try something like this:
>
> E_App temp = new E_App();
> temp.setPrimaryKey(temporaryPK);
> temp = em.merge(temp);
>

Thank you so much, that fixed it, obviously!

-- Pawel.


>
> Thanks,
> Rick
> On Dec 29, 2011 5:47 AM, "Pawel Veselov" <pawel.veselov@gmail.com> wrote:
>
> > Hi.
> >
> > I'm not sure what I'm doing wrong here. I'm creating a temporary entity,
> > within transaction, deleting the entity before committing. I need that
> > temporary entity in the database during the transaction though... My code
> > is roughly doing this:
> >
> > EntityManager em; // have it
> > E_App temp = new E_App();
> > temp.setPrimaryKey(temporaryPK);
> > em.merge(temp);
> > em.flush();
> > // the temporary entity is in the database, as I wanted (verified)
> > // do other crazy stuff now, not touching temp instance in any way
> > // (except from side direct DB queries that don't modify any managed
> > columns)
> > em.remove(temp);
> > em.flush(); // I added that line in hope it might make a difference, but
> it
> > doesn't
> > // some other stuff, also changes persistence context
> > em.getTransaction().commit();
> >
> > The problem is that temp shows up in the database after commit.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message