The title maybe a bit miss leading but not sure how to describe my problem, especially English's not my first language.
I had three classes,
FirmUser Firm and
FormType
A FirmUser has a list of Firms and each Firm has a list of FormTypes
Code:
public class FirmUser{
private List<Firm> firms;
// getter and setter
}
public class Firm{
private List<FormType> formTypes;
// getter and setter
}
public class FormType{
}
They have all been mapped in Hibernate, and fetching mode are all
LAZY.
Here's how I retrieve a list of FirmUsers.
Code:
List results = session.createCriteria(FirmUser.class)
.setFetchMode("firms", FetchMode.JOIN).list();
Now I'v got a list of FirmUser, the 'firms' property of each FirmUser has been initialised, but Hibernate did not fetch 'formTypes' for each firm, because the fetching mode is 'LAZY'
How do I get Hibernate to fetch 'formTypes' for each firm when I try retrieve a list of FirmUser?
Of course I can achieve this by setting the fetch mode to eager, it's not appropriate in my application