This question is locked. New answers and comments are not allowed.
Hi
We're looking at switching from internal identity to single field identity (because we want access to the key value), but still using the HighLow key generator. That's straightforward enough (well documented, thank you) and works fine for our routine scenarios. However, we've hit a problem when we try to use the id of a new persistent object before committing it (it has been added to the scope): the id value is still zero (ie unset). At first I thought this meant the ids weren't set until commit time, but checking later in the sequence (just before commit, in fact), I can see that the ids are getting set prior to commit. My question is when does that happen? (The Object Lifecycle documentation says that calling IObjectScope.Add makes the object state 'persistent new' and "...an object identifier is assigned to the object", but that isn't happening in our setup.)
Experimenting via the debugger, I've found that getting the ObjectId for a new object causes its id to be set (and that may be why I'm seeing the ids close to the commit call - we use the ObjectIds for some book-keeping functionality that's happened by then). I'll use that as a workaround, but it would be preferable to have a definite point at which the id is guaranteed to be set (and if that isn't the Add method, some way to force it).
Best regards, Peter
We're looking at switching from internal identity to single field identity (because we want access to the key value), but still using the HighLow key generator. That's straightforward enough (well documented, thank you) and works fine for our routine scenarios. However, we've hit a problem when we try to use the id of a new persistent object before committing it (it has been added to the scope): the id value is still zero (ie unset). At first I thought this meant the ids weren't set until commit time, but checking later in the sequence (just before commit, in fact), I can see that the ids are getting set prior to commit. My question is when does that happen? (The Object Lifecycle documentation says that calling IObjectScope.Add makes the object state 'persistent new' and "...an object identifier is assigned to the object", but that isn't happening in our setup.)
Experimenting via the debugger, I've found that getting the ObjectId for a new object causes its id to be set (and that may be why I'm seeing the ids close to the commit call - we use the ObjectIds for some book-keeping functionality that's happened by then). I'll use that as a workaround, but it would be preferable to have a definite point at which the id is guaranteed to be set (and if that isn't the Add method, some way to force it).
Best regards, Peter