-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: net.sf.hibernate.collection.Set not deterministic?
PostPosted: Mon Apr 18, 2005 5:47 pm 
Regular
Regular

Joined: Mon Sep 20, 2004 8:42 am
Posts: 58
Location: Boston, US
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.