cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrey Razumovsky <razumovsky.and...@gmail.com>
Subject Re: Rolling back vs deleteobject
Date Sun, 14 Feb 2010 21:00:40 GMT
Hi,

The example is correct. If something's gone wrong during the commit, you'll
need to roll back so that bad data will not be present in next commit
(assuming you're using WebApplicationContextFilter). In
WebApplicationContextFilter there is one context per session.
rollbackChangesLocally() is used to clean only nested context, without
affecting parent context. If you're not creating nested contexts, it works
same as rollbackChanges()

2010/2/12 Marek Ĺ abo <msabo@buk.cvut.cz>

> Hi all,
>
> I would like to know your opininon on this (example adding user):
>
>  try {
>            getObjectContext().commitChanges();
>            return user;
>        } catch (CayenneRuntimeException cre) {
>            //getObjectContext().deleteObject(u);
>            getObjectContext().rollbackChanges();
>        }
>
> I was using deleteObject method but that didn't reccure so foreign key
> objects were left just like that in context, rollback does the trick for me.
> I'm not sure how exactly this rollback works when I'm using
> getThreadObjectContext - will it be unique for every user session on
> webserver?? I hope it's not shared amongst them. And what's the difference
> from the "local" version of rollback?
>
> Thanks in advance,
>
> regards,
>
> Marek
>



-- 
Andrey

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