I have an 'Interview' entity that has a one-to-one mapping with a 'FormSubmission' entity, the Interview entity is the dominant side so to speak, the mapping is:
<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>
Both entities are part of an Aggregate with the Interview acting as the Aggregate Root. I'm trying to Save/Update/Delete the FormSubmission via the Interview entity, hence I have mapped the Interview end of the association as cascade="all-delete-orphan". For instance, I can create a new FormSubmission just fine like this:
myInterview.Submission = new FormSubmission(myInterview);
InterviewRepository.Save(myInterview);
...and this works just fine, the FormSubmission is saved. However, I can't seem to delete the FormSubmission which I'm trying to do like this:
myInterview.Submission = null;
InterviewRepository.Save(myInterview);
...but this doesn't seem to delete the FormSubmission. I've tried assigning null to both sides of the association:
myInterview.Submission.Interview = null;
myInterview.Submission = null;
InterviewRepository.Save(myInterview);
I've even tried setting cascade="all-delete-orphan" on the FormSubmission side, but nothing seems to work. What am I missing?