In addition to @ bigZee77's answer, you can also change your request and the request for a kitten instead of a cat. The resulting list of kittens will be ordered, and each kitten will point to the same cat:
select k from Cat c inner join fetch c.kittens k where c.id = :id order by k.age
If the cat does not have a kitten, you will receive an empty list.
An alternative, of course, is the Java method, sorting the list of kittens.
Jb nizet
source share