Hi,
I have the problem of ordering a set using a property defined in a joined class (Hibernate 2.1.3).
Code:
<class name="Group" ... >
<set name="items" ... >
<key ... />
<one-to-many class="Item"/>
</set>
...
</class>
<class name="Item" ... >
<many-to-one name="type" class="Type" ... />
...
</class>
<class name="Type">
<property name="description" ... />
...
</class>
I'd like to retrieve Groups with their Items ordered by the Type's Description, specifying this in the mapping files.
I'd like to avoid to specify a sort attribute and a comparator for the items, to save CPU cycles (items can be numerous, order of 10,000), and also because the comparator must compare the whole item state, not only the field I'd like to use for ordering (otherwise calling add() to the set will behave strangely).
I have searched this forum and google, but I could not find any solution for this.
Is it possible to tell hibernate to order the items like described ? Or it is a missing feature ? Or am I going the wrong way ?
Has anyone had this problem before, solved it and willing to share the solution ?
Something on the lines of this, maybe ?
Code:
<set name="items" ... hql-order-by="type.description asc">
Thanks in advance,
Simon