「FormSubmission」エンティティと1対1のマッピングを持つ「Interview」エンティティがあります。Interviewエンティティは、いわば支配的な側面であり、マッピングは次のとおりです。
<class name="Interview">
<id name="Id" column="Id" type="Int64">
<generator class="identity" />
</id>
// other props (snip)....
<one-to-one name="Submission" class="FormSubmission"
cascade="all-delete-orphan" />
</class>
<class name="FormSubmission">
<id name="Id" column="Id" type="Int64">
<generator class="foreign">
<param name="property">Interview</param>
</generator>
</id>
// other props (snip)....
<one-to-one name="Interview" class="Interview"
constrained="true" cascade="none" />
</class>
両方のエンティティは、インタビューがアグリゲートルートとして機能するアグリゲートの一部です。Interviewエンティティを介してFormSubmissionを保存/更新/削除しようとしているため、関連付けのInterviewの終わりをcascade="all-delete-orphan"としてマップしました。たとえば、次のように新しいFormSubmissionを作成できます。
myInterview.Submission = new FormSubmission(myInterview);
InterviewRepository.Save(myInterview);
...これは問題なく機能し、FormSubmissionが保存されます。ただし、次のように実行しようとしているFormSubmissionを削除できないようです。
myInterview.Submission = null;
InterviewRepository.Save(myInterview);
...しかし、これはFormSubmissionを削除していないようです。アソシエーションの両側にnullを割り当ててみました:
myInterview.Submission.Interview = null;
myInterview.Submission = null;
InterviewRepository.Save(myInterview);
FormSubmission側でcascade="all-delete-orphan"を設定しようとしましたが、何も機能しないようです。私は何が欠けていますか?