-->
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: HQL specify an order by property order?
PostPosted: Tue May 18, 2010 5:32 am 
Newbie

Joined: Tue May 18, 2010 5:30 am
Posts: 1
How can I order by a specific property order in HQL?

For MySQL I can use:
Code:
SELECT * FROM question q ORDER BY q.status IN ("DONE", "NO_ACTION"), q.status IN ("NEW","SAVED"), q.created DESC


but HQL doesn't allow
Code:
in
in
Code:
order by
.

Am I missing something? Is there some other way around this problem?

Thanks


Top
 Profile  
 
 Post subject: Re: HQL specify an order by property order?
PostPosted: Wed May 19, 2010 12:02 pm 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
You can look into the Criteria API. Very easy to use.
Criteria criteria = session.createCriteria(class)
criteria.add(Restrictions.in(restirctions...)
criteria.orderBy(orderby field) (or some thing like this)


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.