Ordering a join fetched collection in JPA using JPQL/HQL

后端 未结 3 1888
被撕碎了的回忆
被撕碎了的回忆 2021-02-07 14:40

Given the below JPQL statement, how do I modify it so that the kittens in the resulting list are ordered by their age property?

SELECT c FROM Cat c          


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-07 15:16

    I am retrieving time intervals with corresponding time slots, and able to order the records using the property of the child collection in the JPQL query.

    Following works for me.

    SELECT DISTINCT i FROM Interval i INNER JOIN FETCH i.slots s WHERE i.schedulerId = :schedulerId ORDER BY s.startDateTime
    

提交回复
热议问题