我写了这样的代码
criteria.add(Restrictions.eq("lastName", "ChARaN").ignoreCase()); //
默认情况下,这两者都转换为小写。
SQL生成:
select
this_.ID as ID1_0_0_,
this_.EMAIL as EMAIL2_0_0_,
this_.FIRST_NAME as FIRST_NA3_0_0_,
this_.LAST_NAME as LAST_NAM4_0_0_
from
Employee this_
where
lower(this_.LAST_NAME)=?
14:56:57,017 TRACE BasicBinder:81 - binding parameter [1] as [VARCHAR] - [charan]
我希望Hibernate生成大写的查询,如:
where
upper(this_.LAST_NAME)=?
答案 0 :(得分:0)
如果使用UPPER
代替LOWER
,则不确定会有什么好处。说过你尝试下面的选项强制Hibernate使用UPPER
criteria.add(Restrictions.sqlRestriction("UPPER({alias}.lastName) = UPPER(?)", "ChaRaN", StringType.INSTANCE))