Hello Hibernators
I have two tables, VENDOR_SIZE_CHART and VENDOR_SIZE_VALUE. Each VENDOR_SIZE_CHART is associated with many VENDOR_SIZE_VALUES.
VENDOR_SIZE_VALUE has a SORT_ORDER column, I would like Hibernate to use this column to order the collection every time its retrieved. This column can have gaps (i.e. 1,2,3,<gap>,5,6,7) and duplicates. I don't really care about tie breaking order in case of duplicates, but there is a primary key ID column to use.
The end user can update SORT_ORDER through the web application, if that happens the next time VENDOR_SIZE_CHART is updated the VALUE's should be retrieved in the new order.
I'm having trouble implementing this in HBM. Here is my mapping:
Code:
<list
name="vendorSizeValues"
inverse="true"
cascade="all"
>
<key column="VENDOR_SIZE_CHART_ID" not-null="true"/>
<list-index column="SORT_ORDER" base="1"/>
<one-to-many class="com.bluefly.apps.manager.domain.VendorSizeValue" />
</list>
I'm having the following problems:
- I get an ArrayIndexOutOfBounds error when there are duplicate sort order values
- null elements are being placed in the list where the gaps occur, as if the collection was an fixed length array indexed by sort_order
Is there a way to tell Hibernate to not place null elements in the list, and to use the primary key as a tie breaker in case of duplicates?
Thanks!