RE: Accessing last commit status

From: Cris Daniluk (cris.danilu..laraview.com)
Date: Wed Dec 15 2004 - 14:27:44 EST

  • Next message: Andrus Adamchik: "RE: Accessing last commit status"

    Andrus,

    The most concise way I can come up with to describe the issue is something
    like this:

    DataContext ctx = DataContext.getThreadContext(); // pulls context from user
    Session
    Artist noName = (Artist) context.createAndRegisterNewObject(Artist.class);
    noName.setName(null); // required field

    ctx.commitChanges(); // throws runtime exception...

    The exception is handled, but the DataContext's state isn't reset. The same
    user makes another request:

    DataContext ctx = DataContext.getThreadContext(); // pulls context from user
    Session
    Artist picasso = (Artist) context.createAndRegisterNewObject(Artist.class);
    picasso.setName("Picasso"); // required field

    ctx.commitChanges(); // still throws runtime exception

    The DataContext attempts to commit the Artist noName first, before trying to
    commit picasso. It does not reset itself to a safe state after a failure.

    What I'm trying to do is effectively trap the state and react accordingly on
    the subsequent request.

    Hope that is a little more clear,

    Cris

    > -----Original Message-----
    > From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > Sent: Tuesday, December 14, 2004 9:44 PM
    > To: cayenne-use..bjectstyle.org
    > Subject: Re: Accessing last commit status
    >
    > Cris,
    >
    >
    > > [...] persist the context across sessions.
    >
    > > [...] commit fails and escapes error handling,
    >
    > I am not following what you are trying to do... Any code
    > samples, ASCII
    > charts?
    >
    > Andrus
    >
    > On Dec 14, 2004, at 2:12 PM, Cris Daniluk wrote:
    > > Is it possible to access the result of the most recent
    > commitChanges()
    > > method call? We are using the DataContext listener to persist the
    > > context
    > > across sessions. If a commit fails and escapes error handling, it
    > > becomes
    > > stuck in the queue ahead of any other changes, causing all
    > subsequent
    > > page
    > > loads to fail when commitChanges() is called. When the context is
    > > retrieved
    > > in a new request, I would like to first check the last action for
    > > failure,
    > > and if discovered, log and remove all newObjects and
    > modifiedObjects.
    > >
    > > It looks like there are events DID_COMMIT and DID_ROLLBACK that
    > > DataContext
    > > relies on internally. I could not find a publicly exposed way to
    > > access tbe
    > > checked at the beginning of each page request to see if there are
    > > changes
    > > that need to be rolled back.
    > > Is there an easy/proper way to do this, and if not, what
    > would be the
    > > best
    > > way for me to patch DataContext to support it?
    > >
    > > Thanks,
    > >
    > > Cris
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Dec 15 2004 - 14:26:39 EST