I am using a bag. I also would like to know what is best to use for a collection. Its a little hard to determine which is best to use : bag, set, list, or map.
Here are my mappings - probably doesn't mean much now though since you have mentioned that a bag will have the behavior I am seeing/
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="RemoteNet.Northrop.IbisWork.Domain.Model"
assembly="RemoteNet.Northrop.IbisWork.Domain" >
<class name="JobDescriptor" table="JobDescriptor">
<!--ID-->
<id name="Id" column="JobDescriptorId" unsaved-value="0" access="nosetter.camelcase-underscore">
<generator class="identity" />
</id>
<!--VERSION-->
<version name="Version" column="Version" access="field.camelcase-underscore" ></version>
<!--PROPERTIES-->
<property name="Characteristics" column="Characteristics" length="500" access="nosetter.camelcase-underscore"/>
<property name="Status" column="Status" not-null="true" access="field.camelcase-underscore" />
<!--COLLECTIONS -->
<bag name="Functions" table="JobDescriptorFunction" access="field.camelcase-underscore" lazy="true">
<key column="JobDescriptorId" />
<many-to-many class="Function" column="TitleId" />
</bag>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="RemoteNet.Northrop.IbisWork.Domain.Model"
assembly="RemoteNet.Northrop.IbisWork.Domain" >
<class name="Title" table="Title" mutable="false">
<!--CACHE -->
<cache usage="read-only" />
<!--IDENTIFIER -->
<id name="Id" type="System.Int32" column="TitleId" unsaved-value="0" access="nosetter.camelcase-underscore">
<generator class="identity" />
</id>
<!--DISCRIMINATOR -->
<discriminator column="Type" not-null="true" />
<!--PROPERTIES-->
<property name="Name" column="Name" length="75" not-null="true" access="field.camelcase-underscore" unique="true"/>
<property name="Characteristics" column="Characteristics" length="1000" not-null="true" access="field.camelcase-underscore" />
<property name="Status" column="Status" not-null="true" access="field.camelcase-underscore" />
<!--SUB CLASSES-->
<subclass name="Function" discriminator-value="1" >
</subclass>
<subclass name="Designation" discriminator-value="2" >
<property name="JobCode" column="JobCode" length="6" access="field.camelcase-underscore" />
</subclass>
</class>
</hibernate-mapping>