Hi All,
I have the following situation: A domain model which has various
classes that all map to one or more tables in a DB2 database. For
keeping track of versioning our dba guys have written a trigger that
will copy the entire table record into a seperate 'history' version
table.
No worries untill they figured out that with this approach it would be
impossible to track who actually deleted an item. So they went a step
further and made deletes forbidden. Now we would have to update the
record and set the a field to '+DELETE+'. A trigger will then run
afterwards and copy the 'deleted' version to the history and then
fysically delete the row.
So far the intro. I have made an interface IVersionable (because not
all domain objects require this approach) and have written a
IVersionableDeleteEventListener that will do the following:
if (entity is IVersionable)
{
IVersionable versionable = (IVersionable)entity;
versionable.CreatedBy = "+DELETE+";
versionable.LastModification = DateTime.Now;
versionable.LastModifiedBy =
UserContextHelper.GetUserPrincipal();
CascadeBeforeDelete(session, persister, entity, entityEntry,
transientEntities);
CascadeAfterDelete(session, persister, entity,
transientEntities);
}
else
{
base.DeleteEntity(session, entity, entityEntry,
isCascadeDeleteEnabled,
persister, transientEntities);
}
This now conflicts with my cascading rules I have set for this
object. I receive the following error: "deleted object would be re-
saved by cascade"
The problem lies in the fact that A has a collection of B. A is
Versionable while B is not. Thus B should be deleted and A should be
marked for deletion. The cascading options set on A try the re-save B
which results in the above error.
Does anyone have had the same problem and how have you then solved
this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---