Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You would want to use <code>&lt;List /&gt;</code> instead of <code>&lt;Bag /&gt;</code></p> <pre><code>&lt;bag name="Controls" cascade="all-delete-orphan" lazy="false"&gt; &lt;key column="PageConfigurationId" /&gt; &lt;one-to-many class="WidgetConfiguration" /&gt; &lt;index column="SlotOrder" /&gt; &lt;/bag&gt; </code></pre> <p>I notice that you are mapping your collection currently as a <code>Bag</code>. NHibernate supports three kinds of sequenced-collections - <code>Bag</code>, <code>Set</code> and <code>List</code></p> <p>List has ordering semantics, as I guess you are aware, but when no ordering is required, you would normally use a <code>Set</code>.</p> <p>Because a <code>Set</code> mandates that each item is in a collection only once, it is very easy to remove an item using a single delete statement on that item's Id. A <code>Bag</code> does not mandate collection uniqueness, so the only way for NHibernate to delete an item is to delete everything, and then re-add every item that was not the deleted item. (The inverse is adding an item to a <code>Bag</code> can be faster than using a <code>Set</code>, because uniqueness does not have to be enforced)</p> <p>Ayende (one of the main contributors to NHibernate) posted these a while back:</p> <p><a href="http://ayende.com/blog/3943/nhibernate-mapping-set" rel="nofollow">http://ayende.com/blog/3943/nhibernate-mapping-set</a></p> <p><a href="http://ayende.com/blog/4043/nhibernate-mapping-list" rel="nofollow">http://ayende.com/blog/4043/nhibernate-mapping-list</a></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