gpt4 book ai didi

hibernate - HQL 组合 "distinct"和 "order by"

转载 作者:行者123 更新时间:2023-12-01 22:40:59 25 4
gpt4 key购买 nike

如果我删除“distinct”或“order by”,则此查询有效,但合并后无效。我正在尝试遵循示例。你能解释一下吗?

String queryString = "select distinct event.county from Event as event order by event.county.county"

[main] - [ERROR] SqlExceptionHelper.logExceptions():144 >> ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
Position: 215

生成的 SQL

select distinct county1_.Id as Id4_, county1_.County as County4_ from Event event0_ inner join County county1_ on event0_.CountyID=county1_.Id cross join County county2_ where event0_.CountyID=county2_.Id order by county2_.County 

最佳答案

尝试

select distinct county from Event event
inner join event.county county
order by county.county

关于hibernate - HQL 组合 "distinct"和 "order by",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13380069/

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