"join fetch" instructs hibernate to populate the collections from the join results rather than issuing separate selects. However, it is not normally used with a where clause.
There's some discussion of this here (from 2003):
http://forum.hibernate.org/viewtopic.php?p=2203703
... where Gavin King says:
Quote:
This should work. But it is "strange" to use the FETCH clause together with a WHERE condition...
or else the returned collection does not have all its elements!
From your description I think this is what you want - i.e. for the returned collections to contain only those elements matching the query. Be careful never to update the returned objects (especially if relationships are cascaded) otherwise hibernate will delete collection entries that are in the database but not in your object.
Actually it _isn't_ possible to do this with the Criteria API. You can specify setFetchMode(JOIN) but hibernate ignores this when you add a restriction to elements of the collection. You could argue this is the correct behaviour because the objects returned match their database representation i.e. the collections contain all the elements.
Hibernate will need to issue separate selects for the collections (lazy or not) but the impact can be minimised by setting fetch="subselect" to get all the objects for a particular collection in one go.