I think I'm finding that components have a different behaviour than the main mapped class. For example, the following produces a error during an
Update/Save due to the
PERS_ID column being repeated.
Code:
Client cl = new Client();
cl.VendorId = 2;
cl.Contacts.PersonId = 1;
sess.Save(cl);
<class name="Data.Client, Data" table="CL">
<jcs-cache usage="read-write" />
<id column="CL_ID" name="Id" unsaved-value="0" type="Int32">
<generator class="native" />
</id>
<property column="VENDOR_ID" name="VendorId" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate" not-null="false" />
<component class="Data.ClientPersons, Data" name="Contacts">
<property column="PERS_ID" name="PersonId" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate" not-null="false" />
<many-to-one column="PERS_ID" name="Person1" class="Data.Person, Data" cascade="none" outer-join="false" insert="false" update="false" not-null="false" />
</component>
</class>
However, this
Updates/Saves just fine:
Code:
Client cl = new Client();
cl.VendorId = 2;
cl.PersonId = 1;
sess.Save(cl);
<class name="Data.Client, Data" table="CL">
<jcs-cache usage="read-write" />
<id column="CL_ID" name="Id" unsaved-value="0" type="Int32">
<generator class="native" />
</id>
<property column="VENDOR_ID" name="VendorId" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate" not-null="false" />
<property column="PERS_ID" name="PersonId" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate" not-null="false" />
<many-to-one column="PERS_ID" name="Person1" class="Data.Person, Data" cascade="none" outer-join="false" insert="false" update="false" not-null="false" />
</class>
Is this the expected behaviour or should I log this in JIRA as a bug?