openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: detach question
Date Thu, 03 Dec 2009 14:55:59 GMT
When you call cc.merge(ooo); any changes made to that instance while it was
detached will be persisted to the DB.

I assume your comment "Here I modify the ooo but I want this modif to be
persist, not the other one before" means that you only want the changes from
after the tran begins to be persistent... If that assumption is correct,
you'll need to get a new instance of ooo to make the changes on.
-- 
Thanks,
Rick

On Thu, Dec 3, 2009 at 8:49 AM, Jean-Baptiste BRIAUD -- Novlog <
j-b.briaud@novlog.com> wrote:

> Hi the list,
>
> Am i right on the following pseudo code ?
>
>            // Note the detach.
>            // getFullById come back with an instance of MyObject from the
> primary key
>            final MyObject ooo = detach(getFullById(cc....
>
>            < Here I modify (a lot) ooo but don't wan't the modif to be
> persist>
>
>                try {
>                    cc.beginTransaction();
>
>                    <Here I modify the ooo but I want this modif to be
> persist, not the other one before>
>
>                    cc.merge(ooo);
>                    cc.commitTransaction();
>
>                } catch (...) {
>                    cc.rollbackTransaction();
>                }
>
> Thanks !

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