I am having a <list> relationship with one-to-many, like this:
Code:
<class name="Vector" table="VECTORS">
<jcs-cache usage="read-write"/>
<id name="DataID" column="ID" type="Int64" unsaved-value="0">
<generator class="sequence">
<param name="sequence">EQ.APP_SEQ</param>
</generator>
</id>
<property name="Name" column="NAME" type="AnsiString" length="30" access="field"/>
<property name="LineColor" column="LINE_COLOUR" type="AnsiString" length="30" access="field"/>
<property name="LineStyle" column="LINE_STYLE" type="AnsiString" length="30" access="field"/>
<property name="PointStyle" column="POINT_STYLE" type="AnsiString" length="30" access="field"/>
<list name="Algorithms" table="INVOKED_ALGORITHMS" lazy="true" access="field" cascade="all">
<jcs-cache usage="read-write" />
<key column="VCTR_ID"/>
<index column="EXECUTION_ORDER" type="Int32" length="1"/>
<one-to-many class="InvokedAlgorithm" />
</list>
</class>
The class InvokedAlgorithm is the class mapped to the same table "INVOKED_ALGORITHMS", with a ID column mapped to it's <id>
When removing a child from the list of "Algorithms", NHibernate actually update the left records' column of VCTR_ID & EXECUTION_ORDER to null first, then re-set them back with EXECUTION_ORDER has new value. For the 2 columns in our table is not nullable, this 2-step modifying causes problem in my case.
Why don't NHibernate just update the records with new value without doing null first?
I found a similar FAQ in Hibernate website:
http://www.hibernate.org/116.html#A7
This not-null attrb for <key> seems in Hibernate 3 only? Will it prevent Hibernate to set the column to null first then set it back?
How about <index>? Shall it have a "not-null" also?