Hibernate version: 3.1.0
I think there may be a bug in CriteriaImpl$Subcriteria.setFetchMode() when the Subcriteria was created from another Subcriteria.
I'm querying a structure that looks like this:
entity->many-to-one(assoc1)->entity->many-to-one(assoc2)->entity->collection
The following code works (it performs the fetch join on the collection)...
Code:
session.createCriteria (entityClass).
createCriteria ("assoc1").
setFetchMode ("assoc2.collection", FetchMode.JOIN)
...but this doesn't work (the fetch join is not performed)...
Code:
session.createCriteria (entityClass).
createCriteria ("assoc1").
createCriteria ("assoc2").
setFetchMode ("collection", FetchMode.JOIN)
Using the debugger, I noticed that CriteriaImpl$Subcriteria.setFetchMode() calls CriteriaImpl.setFetchMode() with a qualified path. However, in the failing case, the qualified path is "assoc2.collection", not "assoc1.assoc2.collection".
I've simplified the example queries. In reality they contain restrictions at the outer-most and inner-most nesting levels.