简体   繁体   中英

Hibernate case-insensitive utf-8/unicode collation that works on multiple DBMS

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM