The answer from OP may work, but blindly joining two "path" of ~ToMany relationship is going to make the resulting SQL an inefficient query which give cartesian product for the result.
To simplify the story, assume we have entities like this:
public class Message {
@Id
private Long id;
@OneToMany
private Set<Image> images;
@OneToMany
private Set<Description> descriptions;
}
if you are retrieving Message + its images + its descriptions by
from Message
left join fetch images
left join fetch descriptions
where id = :id
if that message contains 100 images and 100 descriptions, the resulting SQL is going to give you 10,000 records.
A more proper way to fetch this is by issuing two queries.
from Message left join fetch images where id = :id
from Message left join fetch descriptions where id = :id
With first-level cache of Hibernate (or any JPA implementation), you can get the result of either one of the queries and you will have both images or descriptions fetched.
Just to avoid confusion, if you have structure like this:
[Foo] 1-->* [Bar] 1-->* [Qux]
It is fine to do
from Foo foo join fetch foo.bars bar join fetch bar.quxs qux where foo.id = :id