NHibernate cascade and inverse

Posted by Kordonme on Stack Overflow See other posts from Stack Overflow or by Kordonme
Published on 2010-08-31T08:41:50Z Indexed on 2011/11/15 9:51 UTC
Read the original article Hit count: 310

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:

  1. When deleting a MainChapter
    • Delete the MainChapterClient row
    • Delete the MainChapterClientDetail row(s)
  2. When deleting a MainChapterClient
    • Do NOT delete the MainChapter row
    • Delete the MainChapterClientDetail row(s)
  3. 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!

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about fluent-nhibernate