Savepoints?

From: Lars Heuer (heue..emagia.com)
Date: Tue Feb 08 2005 - 09:08:20 EST

  • Next message: Andrus Adamchik: "Re: Building with JUnit"

    Hi all,

    Is it possible to create some kind of savepoints in Cayenne?
    What I want: Normally the user creates new objects and manipulates
    them and commits the changes. But at one point the application should
    change several objects (hidden from the the user) but these changes may
    fail for several reasons (business rules etc.). If one change fails
    the changes should be rolled back to the earlier (stable) state that
    was controlled by the user.
    But if everything works fine the changes must be committed by the user
    again (the changes are not committed by the application, only rolled
    back if one of the changes failed).

    May I reach the my goal with the following (pseudo) code?

        DataContext parentContext = getDataContext();
        DataContext subContext = parentContext.createDataContext();
        subContext.setParent(parentContext);
        try {
            // do something
        catch (MyException ex) {
            subContext.rollbackChanges();
        }

    Will the changes created within the subContext automatically submitted
    if the user submits the changes in the parent context?

    Are there better solutions?

    Thanks in advance and best regards,
    Lars



    This archive was generated by hypermail 2.0.0 : Tue Feb 08 2005 - 09:09:19 EST