I have 3 classes A, B and C. Class A contains a set of B and class B contains a set of C. Set B is globally lazy in A and set C is globally lazy in B and both with outer-join set to auto.
In my DAO, I'm trying to get a list of A inner join B inner join C:
Code:
Criteria criteria = session.createCriteria(A.class);
criteria.createAlias("bs", "b", CriteriaSpecification.INNER_JOIN)
.setFetchMode("b", FetchMode.JOIN);
criteria.createAlias("b.cs", "c", CriteriaSpecification.INNER_JOIN)
.setFetchMode("c", FetchMode.JOIN);
criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
criteria.list();
The resulting SQL does indeed show the joins for entities B and C but my log file also shows a bunch of SQL generated when I tried to access the B and C collections.
Note that the data returned is exactly what I want and yes, I really want to perform inner joins. I'm just curious why the all the extra SQL calls are being made when it appears as though everything should have been returned from the first SQL query.
Hibernate version: 3.2.2.ga
Database: Oracle 9i