Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate deletes and recreates one-to-many associations even when I use a list
    text
    copied!<p>OK,</p> <p>I've spent a long time researching this with NHibernate 3.3.1.4. The problem I have it that I have a list, like below:</p> <pre><code> &lt;class xmlns="urn:nhibernate-mapping-2.2" name="Domain.Model.Orders.Order, Domain.Model, Version=1.0.0.21730, Culture=neutral, PublicKeyToken=null" table="Orders"&gt; &lt;composite-id name="ID"&gt; &lt;key-property name="PartitionKey" type="System.Nullable`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt; &lt;column name="PartitionKey" /&gt; &lt;/key-property&gt; &lt;key-property name="ID" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt; &lt;column name="ID" /&gt; &lt;/key-property&gt; &lt;/composite-id&gt; &lt;version generated="always" name="SystemTimestamp" type="BinaryBlob" unsaved-value=""&gt; &lt;column name="SystemTimestamp" /&gt; &lt;/version&gt; &lt;list cascade="none" lazy="false" name="LineItems" table="OrderLineItems"&gt; &lt;key not-null="true"&gt; &lt;column name="PartitionKey" /&gt; &lt;column name="Order_ID" /&gt; &lt;/key&gt; &lt;index&gt; &lt;column name="ListIndex" /&gt; &lt;/index&gt; &lt;composite-element class="MemberSuite.Domain.Model.Orders.OrderLineItem, MemberSuite.Domain.Model, Version=1.0.0.21730, Culture=neutral, PublicKeyToken=null"&gt; &lt;property name="Total" type="System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt; &lt;column name="Total" /&gt; &lt;/property&gt; &lt;/composite-element&gt; &lt;/list&gt; </code></pre> <p>You can see Orders has many OrderLineItems. Whenever I change any lineitem, NHibernate deletes all of the line items and reinserts them; over time, this causes pretty bad index fragmentation. I want to make NHibernate simply update the items that have changed.</p> <p>From what I've read, this is normal behavior for bags, because NH can't uniquely identify an entity in the bag. But for Lists, NHibernate <em>should</em> be able to do this via the List Index - but NH is still doing DELETE-INSERT. So my question is:</p> <p>What should the <strong>hbm</strong> look like for a list that makes NH behave properly?</p> <p>and...</p> <p>Is there a way to generate this HBM with the latest Fluent NHibernate?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload