Re: DataContext.clearFlattenedUpdateQueries vs. ContextCommit

From: Craig Miskell (cmiskel..lbatross.co.nz)
Date: Sat Mar 15 2003 - 20:37:05 EST

  • Next message: Holger Hoffstätte: "Re: DataContext.clearFlattenedUpdateQueries vs. ContextCommit"

    On Sun, 16 Mar 2003, Holger [iso-8859-1] Hoffstätte wrote:

    >
    > As mentioned previously I removed the call to clearFlattenedUpdateQueries
    > from ContextCommit, made it protected to DataContext and moved it into
    > commit(Level) like this:
    >
    > ...
    > try {
    > worker.commit(logLevel);
    > this.clearFlattenedUpdateQueries();
    > } catch (CayenneException ex) {
    > throw new CayenneRuntimeException(ex);
    > }
    > ...
    >
    > While all tests run just fine, I'm not so sure whether this is correct.
    > The docs for clearFlattenedUpdateQueries() say:
    > "Should be called once the queries returned by getFlattenedUpdateQueries
    > have been succesfully executed or reverted and are no longer needed.".
    > The successful case should work, but what should happen if an Exception is
    > raised? Should the arrays still be cleared? This was not the case
    > previously, and I don't know what the right thing would be. Any ideas?
    In it's original incarnation (before being moved to ContextCommit), if an
    exception was thrown, the queries were not cleared. This was under the
    theory that the queries had not successfully executed (any that had
    completed would have been rolledback), and thus, should still be hanging
    around. Essentially, they're still "pending"/

    Of course, when a commit on a Datacontext fails, things tend to be all
    over the place and out of sync (well, my expectation is that something is
    seriously wrong, and there's little chance of successfully recovering the
    DataContext and it's modifications), so it may be a moot point. However,
    in the interests of future debugging (and perhaps some more interesting
    ways of cleaning up from a failure?? urgh, could get really messy), I'd
    suggest they not be cleared.

    Craig



    This archive was generated by hypermail 2.0.0 : Sat Mar 15 2003 - 20:40:21 EST