Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case-insensitive ordering using Hibernate Criteria

I have a query created with Hibernate Criteria like this:


Criteria criteria = db.getSession().createCriteria(Vendor.class);
criteria.addOrder(Property.forName("shortName").asc());
List<Vendor> vendorList = criteria.list();

I would like the ordering to be case-insensitive, equivalent to the HQL query


FROM Vendor ve ORDER BY lower(ve.shortName)

How can I achieve this using Hibernate Criteria?

like image 984
simon Avatar asked Nov 25 '11 13:11

simon


1 Answers

criteria.addOrder(Order.asc("shortName").ignoreCase());
like image 157
erimerturk Avatar answered Oct 06 '22 10:10

erimerturk