-->
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: forcing rows with null to be the last in any sorting order
PostPosted: Thu May 07, 2009 6:46 pm 
Newbie

Joined: Mon Jul 21, 2008 5:40 am
Posts: 16
I would like to be able to have Hibernate sort a
column of data and have the nulls always show up last -- regardless of
the sort order, any idea how to achieve this?

Thanks,


Top
 Profile  
 
 Post subject: Re: forcing rows with null to be the last in any sorting order
PostPosted: Fri May 08, 2009 2:19 pm 
Senior
Senior

Joined: Thu Jan 08, 2009 3:48 pm
Posts: 168
order by coalesce(columnName, maxValue)

coalesce takes the first not null value, meaning if a value is present the the value is taken, otherwise maxValue

Rating is welcome

Patrik


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.