gpt4 book ai didi

hibernate - hibernate : HQL Case Insensitive search

转载 作者:行者123 更新时间:2023-12-03 11:29:22 27 4
gpt4 key购买 nike

我的要求是根据字符串在数据库中进行搜索。

该特定字符串可能以大写形式存储在数据库中。

所以,我将不得不通过 HQL 进行不区分大小写的搜索

我目前的 HQL 是

String query = "from OrganizationContent where orgUrl=:url";
Map<String,Object> parameterMap = new HashMap<String,Object>();
parameterMap.put("url", organizationUrlInput.toLowerCase());

我只能从java端做“.toLowerCase”。现在我需要 hibernate 通过不区分大小写的搜索来获取数据。

感谢您对这位 friend 的帮助

最佳答案

来自 the documentation :

Expressions used in the where clause include the following:

[...]

Any function or operator defined by EJB-QL 3.0: substring(), trim(), lower(), upper(), length(), locate(), abs(), sqrt(), bit_length(), mod()


from OrganizationContent where lower(orgUrl) = :url

关于hibernate - hibernate : HQL Case Insensitive search,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9311214/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com