-->
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: getting list data; sorting and unexpected null
PostPosted: Thu Feb 07, 2008 9:15 pm 
Newbie

Joined: Tue Jan 29, 2008 6:07 pm
Posts: 5
I have a number of mapping collection problems when trying to load data from two tables. The table structure is a simple top level table with a referenced list of locations in the second table.

1a. When I try to automatically load from the table using a list (see locationList below) it returns null as the first item in the list. The remaining items are the correct list of locations. So, if I have 3 locations in the table, Hibernate will return 4 entries in the list, with the first being null, and the rest being the correct "Location" type. Why is this?

1b. Using index column="LOCATION_NBR" lets me specify a sort key, but I want a more complex sort. Is there a way to simply do this?

1c. Is there a reason why I cannot simply specify a database sort (e.g. "order by LOCATION_NBR desc")? This would be much more efficient (due to database indexes) than the Hibernate sort that is currently used. I tried adding a filter and it broke the query.

2. Trying to get around all of these problems, I tried using a set instead (see locationSet below). That makes the null problem go away. However, a Set (by definition) is not guaranteed to have an order. Why then, does it allow me to specify an order-by clause?

Hibernate version: 3.2.0 GA

Mapping documents:
Code:
...
      <list name="locationList" table="LOCATION">
         <key column="ID"/>         
         <index column="LOCATION_NBR"/>
         <one-to-many class="Location"/>
      </list>

Code:
...
      <set name="locationSet" order-by="LOCATION_NBR desc">
         <key column="ID"/>         
         <one-to-many class="Location"/>
      </set>


Name and version of the database you are using: Oracle 10i


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.