Print Page | Close Window

SaveChanges exception and Checkpoints

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=147
Printed Date: 16-Apr-2024 at 3:57am


Topic: SaveChanges exception and Checkpoints
Posted By: Customer
Subject: SaveChanges exception and Checkpoints
Date 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?




Replies:
Posted By: IdeaBlade
Date 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.



Posted By: agrogers
Date 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


Posted By: IdeaBlade
Date 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.




Print Page | Close Window