Code:
<set name="children" order-by="child_id desc" cascade="none" inverse="true">
<key column="parent_id" ></key>
<one-to-many class="Child"/>
</set>
private Set<Child> children = new TreeSet<Child>();
A query
Code:
from Parent parent left join fetch parent.children
brings the children in the right order
Interestingly, without the Child object being implementing comparable or any thing I am able to get the set in the correct order I wanted.
After testing many times, but how is this possible and why am I getting the set in the right order I wanted from a set???
I know that I just cannot add to a TreeSet without the class implementing comparable but not only am I able to add to my TreeSet but also get the set elements in the right order??
Code:
select parent.parent_id, child.child_id from Parent left join children child
order by child_id asc
also brings the children in ascending order