Case-insensitive ordering using Hibernate Criteria
Asked Answered
D

1

9

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?

Downtrend answered 25/11, 2011 at 13:18 Comment(0)
B
25
criteria.addOrder(Order.asc("shortName").ignoreCase());
Betony answered 25/11, 2011 at 13:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.