NHibernate 级联和逆
我有如下三个映射:
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
有许多特定于客户端的章节。客户端特定章节 (MainChapterClient
) 有多种翻译 (MainChapterClientDetail
)
删除规则应如下:
- 删除
MainChapter
时- 删除
MainChapterClient
行 - 删除
MainChapterClientDetail
行
- 删除
- 删除
MainChapterClient
时- 请勿删除
MainChapter
行 - 删除
MainChapterClientDetail
行
- 请勿删除
- 删除
MainChapterClientDetail
时- 请勿删除
MainChapter
行 - 请勿删除
MainChapterClientDetail
行
- 请勿删除
但我无论如何最终都会收到此错误:
删除的对象将被重新保存 级联(从中删除已删除的对象 关联)[Entities.MainChapterClient#39]
我不知道如何设置我的级联了。非常欢迎任何帮助!
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)
- Delete the
- When deleting a
MainChapterClient
- Do NOT delete the
MainChapter
row - Delete the
MainChapterClientDetail
row(s)
- Do NOT delete the
- When deleting a
MainChapterClientDetail
- Do NOT delete the
MainChapter
row - Do NOT delete the
MainChapterClientDetail
row(s)
- Do NOT delete the
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要从两侧删除引用:
You need to remove the reference from both sides :