This works:
<hibernate-mapping>
<class name="Train" table="Trains">
<id column="id" name="id" type="java.lang.String" length="4">
<generator class="assigned" />
</id>
<set name="trips" cascade="all">
<key column="trainId"/>
<one-to-many class="Trip"/>
</set>
</class>
</hibernate-mapping>
But my trips are all naturally ordered by their scheduledDate
. I would like to replace the Set
with a List
. Changing the collection to:
<list name="trips" cascade="all" order-by="scheduledDate">
<key column="trainId"/>
<one-to-many class="Trip"/>
</list>
does not work, since it now requires an <index/>
. I don't want to add an index to my table, because the ordering is given by the date.
Any way this can be done? Or should I just get the Set
from Hibernate, and then sort it myself in code? Seems unnecessary when we already have it ordered by the DB.