Java Mailing List Archive

http://www.gg3721.com/

Home » users.openjpa »

Re: cant update a detached instance

Marc Logemann

2008-08-18

Replies: Find Java Web Hosting

Author LoginPost Reply
>

see comments inline...

> Hi,
>  Possibility:
>
>> Box box = boxDao.findNextFreeBox(BoxType.STANDARD); //
> Does this 'box' an existing persistent box, possibly with _version
> = 1?
>

correct.


>> where boxDao.save() is only a wrapper to em.persist(object)
> then this box should be merged. Attempted to persist() will hit the
> DuplicateKey exception at database which is getting translated to
> EntityExistsException to the application.
>

Ok. this worked of course. Then i need to ask inside the save() method
if this object is detached or not and then do either a em.merge() or a
em.persist() correct?

Marc
©2008 gg3721.com - Jax Systems, LLC, U.S.A.