Hello there! We have the following relationship:
Code:
public class Category{
@OneToMany(mappedBy="parent")
private Set<Category> children;
@ManyToOne
private Category parent;
@OneToMany
private Set<Media> medias;
Is it possible to use HQL to query for this:
for each Category, fetch its children
for each children fetch its medias
return the joining of each category's child medias into one big list
I know I could do this as the pseudo code above, using a for loop, and while the session was opened I would query for it. But it seems to be such an impact on the DB. I wonder if there's a better way to do this
Regards