我是Spring JPA / JPQL的新手,但是尝试复制以下MySQL查询,但没有成功。我们无法克服看起来像语法错误的问题,该语法错误似乎是试图将COUNT()和LOWER()的使用组合在一起的功能。
MySQL(有效)是:
select lower(sdetail_cvalue) as stringValue, count(lower(sdetail_cvalue)) as stringValueCount from where sdetail_cfield not like and sdetail_cfield not like and sdetail_cfield not like group by stringValue order by stringValueCount desc
而我正在尝试的相应JPQL是
SELECT new (lower(sd.searchText) as searchText, COUNT(lower(sd.searchText)) as searchTextOccurrenceCount) FROM sd WHERE sd.searchType not like AND sd.searchType not like AND sd.searchType not like GROUP BY searchText ORDER BY searchTextOccurrenceCount DESC
但是在执行时收到以下错误消息
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found '(' near line 1, column 128 [SELECT new (lower(sd.searchText) as searchText, COUNT(lower(sd.searchText)) as searchTextOccurrenceCount) FROM sd WHERE sd.searchType not like AND sd.searchType not like AND sd.searchType not like GROUP BY searchText ORDER BY searchTextOccurrenceCount DESC]
我已对上面的部分进行了编辑,但是列号(即128)是指“(”在“ lower”和“ sd”之间。
我们尝试了各种方法来解构查询以查明问题,这似乎是我们使用了复合COUNT(LOWER())构造。有没有人有使用JPQL成功实现这样的事情的示例?...预先感谢。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。