You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by behlma <be...@googlemail.com> on 2008/01/14 18:36:46 UTC

One-To-Many Collection - ordering/sorting of the collection elements

Hi guys,
suppose we have a simple one-to-many relationship between Category and
Forum. A Forum also has a "position" (column), that specifies its index
position in a category.

Now this query correctly returns a List of Categories, each with a list of
"child"-forums.

select *
from Category, Forum
where Category.id = Forum.categoryId
order by Category.id,Forum.position asc

The problem however is, that even though the sql correctly sorts the forums
(Forum.position.asc), the Forums actually appear in a random order on the
java side, each time the query gets executed. 

Interestingly I observed the exact same behaviour with hibernate some time
ago, so I thought it might have to do with the way "groupBy" works
internally.

Anyone?

Thanks!

-- 
View this message in context: http://www.nabble.com/One-To-Many-Collection---ordering-sorting-of-the-collection-elements-tp14806634p14806634.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.