I've had this problem before. it's happening because you're using a list collection type. A list is an ordered collection that defines it's ordering based on the list-index-column you provide. If you have one row with an index of 7, hibernate will say 'OK, this is an ordered list, and this element is in position 7'. Therefore it will create a list object with a length of 7 were the first 6 entries are null (as there is not data for those indicies). This is all so that the semantics of the 'list' type are preserved.
If the ordering is significant within your application, then you need to make sure that you are maintaining the index column correctly. If is not, then you can avoid this problem by using one of the unordered collection types, such as a set.
Jason.
|