Order by nullable property simultaneously with ordering by not nullable property in HQL

Posted by Episodex on Stack Overflow See other posts from Stack Overflow or by Episodex
Published on 2010-03-08T14:03:31Z Indexed on 2010/03/08 14:06 UTC
Read the original article Hit count: 369

Filed under:
|

Hi, I have a table called Users in my database. Let's assume that User has only 3 properties

int ID; string? Name; string Login;

If user doesn't specify his name then Login is displayed. Otherwise Name is displayed. I wan't to get list of all users sorted by what is displayed. So if user specified Name, it is taken into consideration while sorting, otherwise his position on the list should be determined by Login. Eventually whole list should be ordered alphabetically. I hope I made myself clear...

Is that possible to do in HQL?

© Stack Overflow or respective owner

Related posts about hql

Related posts about order-by