Hi Friends,
An excerpt from "Pro Hibernate 3":
If you would like to start optimizing performance, you can ask Hibernate to fetch the associated objects and collections for an object in one query. If we were lazy loading with Hibernate, the objects would not be initialized until we accessed them. If we use fetch on a join in our query, we can ask Hibernate to retrieve the objects in the collection at the time the query executes. Add the fetch keyword after the join in the query:
When you use fetch for a query like this, Hibernate will return only Supplier objects, not the Product objects. This is because you are specifying the join so Hibernate knows which objects to fetch (instead of lazy loading). If you need to get the Product objects, access them through the associated Supplier object. You cannot use the properties of the Product objects in expressions in the where clause, for instance. Use of the fetch keyword overrides any settings you have in the mappings file for object initialization.
So what I understand from this excerpt is that:
1. "If we use fetch on a join in our query, we can ask Hibernate to retrieve the objects in the collection at the time the query executes"
AND at the same time
2. "When you use fetch for a query like this, Hibernate will return only Supplier objects, not the Product objects"
My Question: Am I the only one who sees the contradiction between these assertions?