Print Page | Close Window

Why do all temporary ID's get fixed up, not just the ones being saved?

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=200
Printed Date: 30-Aug-2025 at 8:45am


Topic: Why do all temporary ID's get fixed up, not just the ones being saved?
Posted By: Customer
Subject: Why do all temporary ID's get fixed up, not just the ones being saved?
Date Posted: 12-Jul-2007 at 3:29pm
I have created X number of entities and added each one to the PersistenceManager.  When I go to save one of any of them, all entites have an ID generated for them but are not saved.  Why is that the case?  Is there any way around that?



Replies:
Posted By: IdeaBlade
Date Posted: 12-Jul-2007 at 3:29pm
IdeaBlade / DevForce has always resolved all temp ids when a save begins, even for entities that you are not saving. I wrote extensively on this subject recently because - for reasons mysterious to me - there has been a sudden flurry of questions about this. Apparently, more and more folks are tempted to save some but not all of the entities with pending changes/additions/deletions. We discourage this because there are data integrity risks. Saving some but not all of the entities can result in violations of cross-object business rules and lead to inconsistencies that are hard to detect and repair.
 
That said, many customers want to do it anyway and are further disturbed that we are resolving all temp ids instead of just those of the new entities being saved. Again, in principle, no one should care about the primary keys. They are supposed to hold arbitrary values with no intrinisic meaning. But, of course, customers sometimes feel differently - they don't want to see gaps in the id sequence for example.
 
Accordingly, and somewhat at odds with our better judgement, we are going to change our 4 year old practice of resolving all temp ids and allow the fixxing up of only the new entities being saved.  This will be done with a FixUpTempIds property in the SaveOptions class.  Possible enumerated values are All or InSaveListOnly
 



Print Page | Close Window