1
如果我刪除「distinct」或「order by」,但它不起作用,此查詢將起作用。我試圖遵循例子。你能解釋一下嗎?HQL結合了「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
感謝那些工作。 – pethel