javamysqlhibernatedetachedcriteria

How to sort the List<User> of names by using DitachedCriteria in hibernate?


Here, i am posting what i need from you!

DetachedCriteria criteria = DetachedCriteria.forEntityName(DomainEntity.tbl_user.toString);
criteria.addOrder(Order.asc("username"));
List<User> user = dao.getEntities(criteria);

This code is working fine, But sorting the names first UpperCase letters then LowerCase letters. I don't want that way.

But, I want both sorting at a time. Based on the alphabetical order. Here, i am using MySQL database.


Solution

  • Are you looking for case-insensitive ordering ? Then try this :

    Order.asc("username").ignoreCase()