FAQ
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

Search Discussions

  • Andrey Razumovsky at Feb 14, 2010 at 9:01 pm
    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
  • Marek Šabo at Feb 15, 2010 at 12:41 am
    Thanks for clarification Andrey, glad that all is as I hoped it 'd be.
    On 02/14/2010 10:00 PM, Andrey Razumovsky wrote:
    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

    --
    Marek Šabo
    Server Manager
    Club SU CVUT Buben
    Bubenečská Kolej (421)
    XMPP: zeratul021@gmail.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedFeb 12, '10 at 5:18p
activeFeb 15, '10 at 12:41a
posts3
users2
websitecayenne.apache.org

2 users in discussion

Marek Šabo: 2 posts Andrey Razumovsky: 1 post

People

Translate

site design / logo © 2022 Grokbase