Nhibernate - one-to-one mapping with Cascade all-delete-orphan, not removing an orphan

I have an Interview object that has a one-to-one mapping to the FormSubmission entity, so the Interview object is the dominant side, so the display:

<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 objects are part of an aggregate interview that acts as the aggregate root. I am trying to save / update / delete FormSubmission through an Interview object, so I matched the end of the association interview as cascade = "all-delete-orphan". For example, I can create a new FormSubmission form as good as this:

myInterview.Submission = new FormSubmission(myInterview);
InterviewRepository.Save(myInterview);

... and it works fine, formal support is maintained. However, I cannot delete the FormSubmission form, which I am trying to do as follows:

myInterview.Submission = null;
InterviewRepository.Save(myInterview);

... , , FormSubmission. null :

myInterview.Submission.Interview = null;
myInterview.Submission = null;
InterviewRepository.Save(myInterview);

cascade = "all-delete-orphan" FormSubmission, . ?

+5
1

, , . "All-delete-orphan" "--" : https://nhibernate.jira.com/browse/NH-1262. " " "--":

<class name="Interview">
    <id name="Id" column="Id" type="Int64">
        <generator class="identity" />
    </id>

    <property name="Name" />

    <many-to-one name="Submission" unique="true" cascade="all-delete-orphan" />
</class>

<class name="FormSubmission">
    <id name="Id" column="Id" type="Int64">
        <generator class="identity" />
    </id>

    <property name="Name" />

    <one-to-one name="Interview" cascade="all-delete-orphan" property-ref="Submission"  />
</class>

EDIT: jchapman ( NH2.x ), , , / .

+5

All Articles