New Posts New Posts RSS Feed: SaveChanges exception and Checkpoints
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

SaveChanges exception and Checkpoints

 Post Reply Post Reply
Author
Customer View Drop Down
Senior Member
Senior Member
Avatar
User Submitted Questions to Support

Joined: 30-May-2007
Location: United States
Posts: 260
Post Options Post Options   Quote Customer Quote  Post ReplyReply Direct Link To This Post Topic: SaveChanges exception and Checkpoints
    Posted: 12-Jul-2007 at 11:34am

1. I begin a checkpoint

2. Make changes to an object

3. Call SaveChanges

4. Save Changes throws an exception so the database did not get updated

After the exception I cannot rollback the checkpoint. 

How should I revert to the changes before the checkpoint in this case?

Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Posted: 12-Jul-2007 at 11:35am

PersistenceManager will clear all Checkpoints before saving any data.  It is under the assumption that all data currently inside the Pm are valid and ready to be saved – thus all Checkpoints and their data are no longer needed.  So there is no way to rollback any Checkpoint after a SaveChanges call.

Even SaveChanges throws an exception because a save failure, your Pm still contains the same/correct data that you intended to save – with no Checkpoint.

You may start new Checkpoints afterward.  I would think you may want to do a SaveEntitySet call to save the current Pm data to a file for later recovery (in case the data-source connection is restored).

If you absolutely must revert the changes before the checkpoints and a SaveChanges call, you can use SaveEntitySet to save Pm data into a file before any checkpoint.  When appropriate, you can revert the Pm data with a RestoreEntitySet call.

Back to Top
agrogers View Drop Down
Groupie
Groupie
Avatar

Joined: 11-Mar-2010
Posts: 41
Post Options Post Options   Quote agrogers Quote  Post ReplyReply Direct Link To This Post Posted: 13-Mar-2014 at 8:37am
>>  It is under the assumption that all data currently inside the Pm are valid and ready to be saved � thus all Checkpoints and their data are no longer needed

Is this still the case in the Classic version of IdeaBlade?

The assumption doesn't seem to make sense to me so maybe I am missing something. I want to use a checkpoint so that i can easily roll back changes that I cannot persist to the server. However I dont know they cannot be persisted until i try to persist them with the SaveChanges call using the IsTransactional option.

So the persist fails but no harm is done as it fails in its entirety since it is transactional. However now I need to undo the changes made to the entity objects in the cache. My Checkpoint is perfect for this... except if my checkpoint is cleared *before* the SaveChanges. 

How do we get rid of the changes to records in the cache if a transactional persist fails?

thanks
Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Posted: 03-Apr-2014 at 10:32am
This is still the case in DevForce Classic since you can’t restore a checkpoint after a Save, this is not what checkpoints were designed for.
The previous answer describes what you need to do to revert changes if you need to.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down