I don't think so. I'm looking at my code and the mappings look fairly much the same as what I've posted before. I also notice that I've commented out my unit tests where I test adding add deleting. Likely because I've gone through a bit a design change.
In some other projects, I manage deleting objects myself. Either through setting the cascades on the database itself. Or, before deleting the parent, I go through and delete the children first. If this is the case, the mapping needs to be changed so that I'm persisting additions only.
Change Cascade to save-update or none, if none you would have to completely manage the collections yourself.
Code:
BeginTransaction();
if(guideline.Factors != null){
foreach(Factor f in guideline.Factors){
if(f.Criteria != null){
foreach(Criterion c in f.Criteria){
Session.Delete(c);
}
Session.Delete(f);
}
}
Session.Delete(guideline);
If the database has cascade deletes enabled, all you should have to do is delete the parent and the database will purge the rest.
I'm hoping to readdress this in the next few weeks.
Darin