I was following the examples in the 'Java Persistence and Hibernate' book with Hibernate 3.3.1 to try and load my collection upfront using fetch=join as follows:
I would expect that when I do a session.get(Person.class, personId), that I would automatically fetch any associated Telephones and would not have to do e.g.
However, the collection is not being fetched.
I tried putting lazy="false" in with fetch="join" and all that seemed to happen was an n+1 selects generated (which I want to avoid).
The 'problem' is that I did not eagerly fetch the parent collection also using a fetch="join"; I fetched it using Hibernate.initialize(parentCollection).
I thought this would have then loaded it, and my fetch="join" on the child collections would have kicked in, but no.
I don't quite understand why Hibernate.initialize doesn't effectively eager-fetch the parent collection.