Currently, I am retrieving a list of users, then iterating through the list and initializing a collection on each, like so:
Code:
userlist = session.find("from User as user order by username");
...
while(iter.hasNext()){
User user = (User)iter.next();
Hibernate.initialize(user.getTeams());
}
This works fine, but each time a collection is initialized, a separate SELECT statement is sent to the DB. Is there a more efficient way to do this, some sort of bulk init, or can I somehow init the collections within my HQL? I don't want to turn off lazy init for this entity, since I only use this collection in one use-case.