views:

270

answers:

1

I'm looking for Hibernate annotation or .hbm.xml that allows me to specify a table column as case-insensitive string working in unicode/utf-8/locale-independent manner that works on multiple database engines.

Is there any such thing?

So that I can do query using Restrictions.eq("column_name", "search_string") efficiently.

A: 

No, there's no mapping or annotation like that. Your options are:

  1. Handle this by specifying appropriate collation at the database level.
  2. Use lower() function that's defined for majority of (all?) dialects.
  3. If you want to use Criteria only, use Restrictions.ilike() for case-insensitive comparison. It actually uses lower() internally.
ChssPly76