pet*_*hel 1 hibernate jpa hql jpa-2.0
如果我删除"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
Run Code Online (Sandbox Code Playgroud)
生成的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
Run Code Online (Sandbox Code Playgroud)
试试吧
select distinct county from Event event
inner join event.county county
order by county.county
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5312 次 |
| 最近记录: |