Reputation: 2273
I have an ordered collection of objects with a Position
field , when retrieving the collection Nhibernate
puts a null
in the gaps between indecies [eg: 0-object, 1-null , 2-null , 3-object ...]
I have this mapping:
<list name="CheckListItems" lazy="true" inverse="true"
batch-size="25" cascade="all-delete-orphan">
<key column="TopicID" />
<index column="Position" />
<one-to-many class="CheckListItem" />
</list>
I want NHibernate to order my list according to the Position field without regards to gaps.
Upvotes: 1
Views: 634
Reputation: 8448
This is NHibernate features which I believe cannot be turned off. If there are holes in an indexed list then NHibernate inserts null in the place of the holes. That exactly the behavior you are seeing.
As suggested by Ayende in his blog post, your application should make sure that whenever there are holes in an indexed list, the index property is recalculated to make sure there are no holes if that is the behavior you want. NHibernate cannot do that for you.
Upvotes: 1