Hi,
I want to map a collection, not to the primary key, but to a property.
How do I do that?
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="SD.Entities.Client, SD.Entities" table="Client">
<id name="UniqueIndex" column="UniqueIndex" type="int" unsaved-value="0">
<generator class="identity" />
</id>
<property name="ClientId" column="ClientID" type="int"/>
<bag name="Pages" lazy="true" order-by="Title ASC">
<key column="ClientId"/>
<one-to-many class="SD.Entities.Page, SD.Entities"/>
</bag>
</class>
</hibernate-mapping>
I want to map the bag Client.ClientId == Page.ClientId but now when I run the code it maps Client.UniqueIndex == Page.ClientId
From the other way it works fine, I just use proerty-ref to select correct property.
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="SD.Entities.Page, SD.Entities" table="Page">
<id name="UniqueIndex" column="UniqueIndex" type="int" unsaved-value="0">
<generator class="identity" />
</id>
<property name="PageId" column="PageID" type="int"/>
<many-to-one name="Client" class="SD.Entities.Client, SD.Entities" column="ClientID" property-ref="ClientId" lazy="false" fetch="join" />
</class>
</hibernate-mapping>
It's the bag that is the problem, it select the wrong pages!
Can I change the bag to something else?