Hibernate version:2.1.8
When I look up a collection (List) by running the HQL
Code:
from Child c where c.parent=?
the order of entries returned is deterministic. ie no matter how many times I run it (across hibernate sessions) the order is the same.
However when I get the same Collection via association
Code:
Set set = parent.getChildren()
the order is non deterministic. The iterator of the set returns elements in different order on subsequent runs. I realize this is a Set and not a List so the order should not necessarily correspond to the order returned by the database query however I would expect the order to be deterministic.
I am implementing a Paged table. I get the correct number of rows and all, however when I try to navigate to the next page, I get the Collection by association in my web controller using parent.getChild() and based on page size and current page, return the subset of elements.
The problem being that the values returned on subsequent calls to parent.getChild() returns elements in different orders and so when I navigate to the next page, I may end up with elements that were previously displayed to the user on the first page.
Do you have any recommendations to work around this?
Thanks,
Sanjiv
Mapping documents:Code:
<class name="test.Child" table="child">
<id name="id" column="child_id" type="long" unsaved-value="null">
<generator class="sequence">
<param name="sequence">child_sequence</param>
</generator>
</id>
<property name="name" column="name"/>
<many-to-one name="engagement" column="parent_id"
class="test.Parent"/>
</class>
<class name="test.Parent" table="parent" lazy="false">
<id name="id" column="parent_id" type="long" unsaved-value="null">
<generator class="sequence">
<param name="sequence">parent_sequence</param>
</generator>
</id>
<property name="name" column="name"/>
<set name="children" inverse="true" lazy="true" table="child" cascade="all-delete-orphan">
<key column="parent_id"/>
<one-to-many class="test.Child"/>
</set>
</class>
Name and version of the database you are using: Oracle 9i