-->
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: How to Handle Blank When Sorting?
PostPosted: Thu Jul 13, 2006 6:51 pm 
Newbie

Joined: Tue Jul 11, 2006 11:11 am
Posts: 2
I was able to specify the Criteria to sort records in my database table. But, some records under certain table fields are blanks. In case that certain fields have null value records, the sorting does not work. How is the situation supposed to be handled:

Code:
Criteria crit = session.createCriteria( User.class );
String sortBy = aSortUsersTO.getSortBy();
String orderBy = aSortUsersTO.getOrderBy();

if ( orderBy.equals( "DESC" ) )
{ crit.addOrder( Order.desc( sortBy ) ); }
else
{ crit.addOrder( Order.asc( sortBy ) ); }

return crit;


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 13, 2006 7:47 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
What happens that you're not expecting? order by handles null values (null is considered the lowest value).

_________________
Code tags are your friend. Know them and use them.


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.