Case sensitive Search in Hibernate Criteria

后端 未结 5 670
礼貌的吻别
礼貌的吻别 2020-12-09 06:49

I\'m using Hibernate 3 with SQL Server 2008. I want to do case sensitive search in Hibernate Criteria. I\'m not able to achieve it. My code is as below:

Crit         


        
5条回答
  •  醉梦人生
    2020-12-09 07:44

    You can't with hibernate. Problem is in MS SQL - by default it use case insensitive collation. There can be two workarounds:

    1 Select with hibernate and do program filtering of result

    2 When create table use case sensitive collation for filed you nead to search: COLLATE SQL_Latin1_General_CP850_BIN2 or other specified for your server (read from SYSTEMPROPERTY).

提交回复
热议问题