One-To-Many collection with a lot of additional null objects #3272
-
I upgraded NHibernate from 3.3.5 to 5.3.14 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This happens because the indexes of the elements of the list are not sequential, but there are gaps: if your index column has gaps in it (i.e. it has values like 3, 4, 5), NH would populate the resulting List with empty elements at the expected places (0,1 and 2). This behavior is by design as you can read at paragraph 6.3.2 of NH reference guide: 6.2.3. Indexed collections To avoid Cannot simultaneously fetch multiple bags you can map with unordered Set. |
Beta Was this translation helpful? Give feedback.
This happens because the indexes of the elements of the list are not sequential, but there are gaps: if your index column has gaps in it (i.e. it has values like 3, 4, 5), NH would populate the resulting List with empty elements at the expected places (0,1 and 2). This behavior is by design as you can read at paragraph 6.3.2 of NH reference guide:
6.2.3. Indexed collections
All collection mappings, except those with set and bag semantics, need an index column in the collection table.
An index column is a column that maps to an array index, or IList index, or IDictionary key. The index of an
IDictionary may be of any basic type, mapped with . It can be an entity reference mapped with
(or i…