-->
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.  [ 3 posts ] 
Author Message
 Post subject: Criteria order by expression
PostPosted: Mon Feb 05, 2007 1:36 pm 
Senior
Senior

Joined: Tue Sep 13, 2005 2:01 am
Posts: 137
I am using DetachedCriteria to build a query dynamically, and need to add a "order by" clause:
order by locate('keyword', name) desc

I tried
criteria.addOrder(Order.desc("locate('keyword', name)");

But I got error, complaining
locate('keyword', name) is not a valid property.

So Order.desc only accepts property, not expression.

Is there a workaround?

Thanks,
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 12:08 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
hi javatwo

You can use your custom locate method which map property by user given value. Why every thing you guys are expecting from Hibernate. Hibernate is not a magic.

locate('keyword', name)

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 10:53 am 
Senior
Senior

Joined: Tue Sep 13, 2005 2:01 am
Posts: 137
Hi Dharmendra,

Thanks for your reply. But I do not understand the solution you suggested. It would be great if you can explain it to me in more detail. Thanks!
Dave


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.