I have a problem width Polymorphic association in nhibernate.
DocumentLocation Mapping :
<class name="Document.DocumentLocation" table="DocumentLocation">
<id name="DocumentLocationId" type="Int32" unsaved-value="null">
<column name="DocumentLocationId" length="4" sql-type="int" not-null="true" unique="true" index="PK_DocumentLocation"/>
<generator class="increment" />
</id>
<many-to-one name="Parent" class="DocumentLocation">
<column name="ParentDocumentLocationId" length="4" sql-type="int" not-null="false"/>
</many-to-one>
<many-to-one name="Document" class="Document" not-null="false">
<column name="DocumentId" length="4" sql-type="int" not-null="true"/>
</many-to-one>
<joined-subclass name="Receiver" schema="document" lazy="true" table="Receiver">
<key>
<column name="DocumentLocationId" length="4" sql-type="int" not-null="true" unique="true"/>
</key>
<one-to-one name="Refer" property-ref="Receiver" cascade="all-delete-orphan" class="Refer" />
</joined-subclass>
<joined-subclass name="Sender" schema="document" lazy="true" table="Sender">
<key>
<column name="DocumentLocationId" length="4" sql-type="int" not-null="true" unique="true"/>
</key>
</joined-subclass>
</class>
There is an one-to-many association in document class
<bag name="Receivers" inverse="true" lazy="true" cascade="all-delete-orphan" >
<key column="DocumentId"/>
<one-to-many class="DocumentLocation"/>
</bag>
But Receivers contain both Sender and Receiver. Is there anyway to tell nhibernate select only one subclass in polymorphic association?