-->
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.  [ 4 posts ] 
Author Message
 Post subject: Order by greatest in HQL?
PostPosted: Fri Jan 19, 2007 2:06 am 
Regular
Regular

Joined: Sun Sep 17, 2006 2:48 am
Posts: 81
Location: California
Hibernate version 3.2.1

Can anyone please tell me the equivalent of the following mysql statement in HQL.

select * from abc order by greatest(created_date, ifnull(modified_date,0));


I am not able to find the equivalent of the bold part in HQL.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 20, 2007 1:04 pm 
Newbie

Joined: Thu Jan 18, 2007 12:55 am
Posts: 10
There are lot of times when native database specific queries cannot be executed with HQL. During those time , use of native sql queries with hibernate is recommended.

Look at the refrence at
http://www.hibernate.org/hib_docs/v3/re ... rysql.html

this should solve your problem if you wan't database specific advanatges that are not offered by HQL


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 20, 2007 2:12 pm 
Regular
Regular

Joined: Sun Sep 17, 2006 2:48 am
Posts: 81
Location: California
Thanks for the reply.

I had done it in native SQL, but I felt that this feature is so common that it must be supported by almost all DB types and therefore must be supported by HQL. The application that I am developing needs to support multiple DB types in the future, so I am a bit reluctant to use native SQL since then those pieces of code will have to be changed.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 20, 2007 2:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if greatest() is just a sql function then map it as such in your Dialect and it will work.

_________________
Max
Don't forget to rate


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