There is no ilike
equivalent functionality in HQL. As Konstantin has already pointed out in his suggestion, your best choice is to tune the database connection and set collation to TERRITORY_BASED:SECONDARY
, as explained in this JIRA: DERBY-1748: Global case insensitive setting.
Take into account that all equalities (=
) and like
s will be case insensitive. This might go a bit too far, and be not suitable for your particular situation.
Another way of addressing this would be creating function-based indexes (if Derby supports them, of course) and tune your HQL to combine like
and lower
like this.
Query q = session.createQuery("... WHERE lower(entity.field) like lower(?)");
q.setString(0, '%' + variable + '%');
If Derby doesn't support FBI's (I think it doesn't), you could also create trigger-filled columns with the lower values and index them.
UPDATE It seems to be possible to define derived/autogenerated columns, as explained in this other JIRA: JIRA-481: implement SQL generated columns.