I have 2 entities: car and wheels (oneToMany) and I want to retrieve my car, with all the wheels and (this is the tricky part) ordered by wheels.location.
Select c from Car LEFT JOIN FETCH c.wheels order by c.wheels.location doesn't work: "illegal attempt to dereference collection".
Any idea how to do this and if this is possible in HQL?
From stackoverflow
-
SELECT DISTINCT c FROM Car LEFT JOIN FETCH c.wheels AS wheels ORDER BY wheels.location -
Hmm. Think you might need to use an alias?
Select c from Car LEFT JOIN FETCH c.wheels wheel order by wheel.location
0 comments:
Post a Comment