我有一个看起来像这样的查询:
SELECT DISTINCT share.rooms
FROM Shares share
left join share.rooms.buildingAdditions.buildings.buildingInfoses as bi
... //where clause omitted
ORDER BY share.rooms.floors.floorOrder, share.rooms.roomNumber,
share.rooms.firstEffectiveAt, share.shareNumber, share.sharePercent
这导致以下异常:
Caused by: org.hibernate.exception.SQLGrammarException: ORA-01791: not a SELECTed expression
如果我删除 DISTINCT 关键字,则查询运行没有问题。如果我删除 order by 子句,查询将毫无问题地运行。不幸的是,我似乎无法获得没有重复的有序结果集。