Given the following collection mapping in an hbm mapping file:
<class name="Parent" table="
ParentTable">
<id name="ID" column="ID" type="Int32" unsaved-value="0">
<generator class="identity" />
</id>
<list name="SomeChildCollection" table="
SomeChildTable " lazy="true" access="nosetter.camelcase-underscore">
<key column="ParentTableID" />
<list-index column="SequenceIndex"" />
<element column="SomeTextField" type="String" length="50" />
</list>
If, somehow, the values of SequenceIndex includes a gap (let's say, for a specific ParentTableID of 20, there are records in SomeChildTable with a SequenceIndex of 0, 1, and 5), NHibernate will fill the collection with null objects for each one of the index values missing: object, object, null, null, null, object
Why?
How do I stop this?
Granted, I don't specifically WANT there to be gaps. If there is a gap, it must be some sort of data or concurrency issue. But I also don't actually CARE if there are gaps. I just want the SeqienceIndex field to indicate order. From a business logic perspective of my application, gaps or no gaps makes no difference. I just don't want null objects in my collection.
I am using the list-index field to sort the fields in order, like if I were using <bag order-by="SequenceIndex"> but where I want NHibernate to update the index field instead of me dealing with it by hand.
Is this considered a feature? Will this ever be changed?