I am using Hibernate JPA 1.0.
I have the following type of model and I consider manyToOne and oneToOne relationships "eagerly" fetched and oneToMany "lazily" fetched.
I want to fetch Entity A and all its associations where a.id=?
then...
          -  B oneToOne C
 + C oneToMany D
 
-  B oneToOne E
 + E oneToMany D
 
-  B oneToOne F
 + F oneToMany D
Is it possible to load this entity in a single query? Or in a subset of queries baring in mind the "n+1 selects problem"!
So far my solution to loading all of A associations was to perform the following:
Code:
"Select DISTINCT a from A a JOIN FETCH a.bs WHERE a.id=:aID"
And then iterate using code in order to fetch all other associations.
Code:
Collection B bs = A.getBs();
         for (final B b : bs) {
         b.getCs().getDs().size();
         b.getEs().getDs().size();
         b.getFs().getDs().size();
         }
Obviously there must be a better way of doing this.