我有2个实体:汽车和车轮(oneToMany),我想检索我的汽车,其中有所有车轮,并且(这是棘手的部分)由wheels.location排序。下面的代码引发异常,并显示消息“非法尝试取消引用集合”。
Select c from Car LEFT JOIN FETCH c.wheels order by c.wheels.location
任何想法如何做到这一点,如果这可以在HQL中进行?
SELECT DISTINCT c FROM Car LEFT JOIN FETCH c.wheels AS wheels ORDER BY wheels.location