Anoop LL
Anoop LL

Reputation: 1575

Hibernate Criteria Order not working

Am using hibernate criteria to fetch data from database. Now i need to fetch data based on title and createdDate, for that i added

if(condition){
 criteria.addOrder(Order.asc("title"));
}else{
 criteria.addOrder(Order.asc("createdDate"));
}

The issue is, its working for createdDate but not for title

Iam getting the result as TEST,d1,ga,new,pre,ss,t which should be like d1,ga,new,pre,t,TEST

UPDATE: The issue is with case, when i changed TEST to test its coming as proper.

Upvotes: 0

Views: 1005

Answers (1)

Lucas Sa
Lucas Sa

Reputation: 41

Try with criteria.addOrder(Order.asc("title").ignoreCase());

Upvotes: 2

Related Questions