NHibernate cascade and inverse
- by Kordonme
I have three mappings as follows:
public MainChapterMap()
{
// other properties
HasMany(x => x.ClientSpecific).KeyColumn("MainChapterId");
}
public MainChapterClientMap()
{
// other properties
References(x => x.MainChapter).Column("MainChapterId");
HasMany(x => x.Details).KeyColumn("MainChapterClientId");
}
public MainChapterClientDetailMap()
{
// other properties
References(x => x.MainChapterClient).Column("MainChapterClientId");
}
MainChapter has many client-specific chapters. The client-specific chapters (MainChapterClient) has many translations (MainChapterClientDetail)
The dele rules should be as follow:
When deleting a MainChapter
Delete the MainChapterClient row
Delete the MainChapterClientDetail row(s)
When deleting a MainChapterClient
Do NOT delete the MainChapter row
Delete the MainChapterClientDetail row(s)
When deleting a MainChapterClientDetail
Do NOT delete the MainChapter row
Do NOT delete the MainChapterClientDetail row(s)
But I no matter what I end up getting this error:
deleted object would be re-saved by
cascade (remove deleted object from
associations)[Entities.MainChapterClient#39]
I'm not sure how to set up my cascades anymore. Any help are more than welcomed!