Implementing a RollBack in the Disconnected API

3 posts, 1 answers
  1. James Denning
    James Denning avatar
    24 posts
    Member since:
    Apr 2009

    Posted 02 Sep 2009 Link to this post

    I see that the ObjectContainer Transaction Rollback method throws a not implemented exception. So what I want to do is reset the ObjectContainer content back to before the ObejctContainer Transaction was opened by getting the CHangeSet discarded and repopulaitng the ObjectContainer with the original data entity that was updated - however preferably I do NOT want to discard the entire ObjectContainer as I would need to repopulate it with a lot of reference data (I suppose I could maintain a reference data Container and transfer its content to a new ObjectContainer to be used for updates BUT keeping it synchronised would be complex).

    So my question is can I commit the transaction, then extract and discard the ChangeSet and then refresh the objects I changed with the original versions by applying a new ChangeSet from the server? Would there be any issues regarding the object state - will there be a problem replacing a dirty object?

    Also I am unclear what ObjectContainer.Transaction.Flush() does - can it be clarified what it does when called if you have a Container with an open transaction and changes made.

    Are there plans to implement RollBack() for the disconnected API?

  2. Answer
    Alexander avatar
    727 posts

    Posted 04 Sep 2009 Link to this post

    Hi James Denning,

    The optimal workaround at the moment is the following:
    • Before starting a transaction that may end up with a rollback, extract a ChangeSet from the container; We will use this change set as a "restore point";
    • Start a transaction;
    • Modify some objects in the container; 
    • To rollback the changes, create new container;
    • Apply the previously extracted change set to the new container;
    The code would look like this:
    ObjectContainer.ChangeSet set = container.GetContent(); 
    // do some changes 
        container = new ObjectContainer(); 

    Providing Rollback functionality for ObjectContainer is on our list but at this point we cannot give an exact time-frame for implementing it.

    The Flush() method is used to commit the dirty and new objects to the database and evict the cache content during transaction. However, it does not make much sense to use this method with object containers as nothing is physically committed to the database.
    Hope that helps.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. James Denning
    James Denning avatar
    24 posts
    Member since:
    Apr 2009

    Posted 07 Sep 2009 Link to this post

    Thanks for the reply - I hadn't thought of extracting a changeset at the point of commit.

Back to Top