-->
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.  [ 2 posts ] 
Author Message
 Post subject: Ordering collections in HQL, possible?
PostPosted: Wed May 09, 2007 2:58 pm 
Newbie

Joined: Mon Mar 26, 2007 5:26 am
Posts: 10
Hibernate version:3.2

Hay buddies

Can I in HQL order an association? Say for instance I have "from User u left join fetch u.messages where u.id = ?"

Can I order the messages in the actual HQL? I've noticed that when using HQL the mapped collections aren't ordered the way you'd want them, even though you might map something like:

<set name="messages" cascade="all" order-by="created desc">

Help!

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 09, 2007 4:36 pm 
Beginner
Beginner

Joined: Thu Apr 12, 2007 3:26 am
Posts: 35
Location: Germany
Sets can't be ordered, because the sense of sets is that they don't contain duplicates and that they are unordered.

But if you declare your message attribute as Collection instead of Set, your order-by attribute (I'm only working with annotations so I won't put my hand into the fire for it) should work. Attributes of type collection can be ordered.

Hoeft


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

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.