Based on reading
http://www.hibernate.org/hib_docs/refer ... nents.html Section 7.4 I am confused about how to map a Class with a composite key that then has a collection of children. The document seems to say that you have to pass the composite key some how but I can't deduce it.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo" assembly="MyBiz" namespace="MyBiz.Model">
<class name="Industry" table="SSC_Industry">
<composite-id name="Id" class="CompositeKey" unsaved-value="any" access="property">
<key-property name="Key" type="String" column="Id"/>
<key-many-to-one name="Language" class="Language" column="Language"/>
</composite-id>
<property name="Name" column="Name" type="String" />
<bag name="Sectors" inverse="true" lazy="false" cascade="all">
<key column="ParentId" />
<one-to-many class="Sector" />
<!-- Problem Area -->
</bag>
</class>
<class name="Sector" table="SSC_Sector">
<composite-id name="Id" class="CompositeKey" unsaved-value="any" access="property">
<key-property name="Key" type="String" column="Id"/>
<key-many-to-one name="Language" class="Language" column="Language"/>
</composite-id>
<property name="Name" column="Name" type="String" />
<many-to-one name="Industry" class="Industry" not-null="true">
<column name="ParentId"/>
<column name="Language"/>
</many-to-one>
</class>
</hibernate-mapping>
Problem AreaWhat should be here?
Code:
<bag name="Sectors" inverse="true" lazy="false" cascade="all">
<key>
<column name="ParentId"/>
<column name="Language"/>
</key>
<one-to-many class="Sector" />
</bag>
Thanks!