I have an association mapped as a List. There's a column in the table that the List data comes from, specifically for indexing the List. However, as records are deleted, the index in the List becomes sparse. Eg 0,1,4,5
When this happens the List can no longer be sorted using Collections.sort.
I've tried creating another ArrayList and populating in from the mapped List and using add(0, myObject), add(1, myObject) so as to create a non-sparse List. However the List is still sparse and sorting doesn't happen because of a null pointer. It corrects itself as soon as the index column is no longer sparse.
Why is this please, and does anyone have any suggestions?
|