Ignorecase for In-Criterion

hibernate, hibernate-criteria, java

Solution

Get the source code of the Criterion class returned by `Restrictions.in()` (`InExpression`), and create another one which is similar but transforms all the elements of the value list to lowercase, and generates a SQL query like:

lower(prop) in (...)

Problem

i'd like to select items case insensitive with an In-Criterion with Hibernate Criteria API. E.g. ``` Criteria crit = session.createCriteria(Item.class); crit.add(Restrictions.in("prop", valueList).ignoreCase()); ``` Unfortunately the Criterion class doesn't has an ignoreCase method. HQL is not an alternative.

Original source