Code:
<hibernate-mapping>
<class name="org.appfuse.model.Category" table="CATEGORY">
<id name="id" type="long" column="CATEGORY_ID">
<generator class="increment"/>
</id>
<property name="name" type="string" column="CATEGORY_NAME" not-null="true"/>
<list name="parents" table="CATEGORY_PARENTS">
<key column="CATEGORY_ID"/>
<index column="POSITION"/>
<many-to-many class="org.appfuse.model.Category" column="PARENT_ID"/>
</list>
<set name="children" table="CATEGORY_CHILDREN">
<key column="CATEGORY_ID"/>
<many-to-many class="org.appfuse.model.Category" column="CHILD_ID"/>
</set>
</class>
</hibernate-mapping>
I'd like to be able to sort the set I get from getChildren() in ascending order based on Category.name. You're probably wondering why I wouldn't just make it a list, but this needs to be flexible, and I don't want to have to update the position column everytime we add a new category to make sure they're in alphabetical order. Is there a simple way to sort a set in hibernate?[/code]