jpa case-insensitive in-clause for a list of string values

僤鯓⒐⒋嵵緔 提交于 2019-12-01 08:46:29

问题


I want to know if JPQL is capable of doing a case-insensitive search on a collection of string.

Scenario:

Table1:

Column1 (int)  | Column2(string)
1                ABC
2                XYZ

I am looking for a JPQL query which does something like this

from Table1 a where upper(a.column2) in upper(:listOfCol2Values)

Can I achieve this without having to change the case at the application code where i set the collection.

Cheers.


回答1:


No you cannot. Reason is that UPPER and LOWER operate to the strings, so they do not take collection as argument.




回答2:


You can always do :

from Table1 a where (upper(a.column2) = upper(:value1) 
    or upper(a.column2) = upper(:value2) 
    or ...)


来源:https://stackoverflow.com/questions/9178290/jpa-case-insensitive-in-clause-for-a-list-of-string-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!