When using the criterias and many-to-many association, if you make a new "Sub Criteria", hibernate removes the outer join "
" from the where statement:
---------
---------
---------
---------
---------
---------
---------
---------
---------
A<B>C
A and C have a many-to-many relationscip trought B.
If i write:
--------
Criteria criteria = session.createCriteria(A.class);
criteria.setFetchMode("B", FetchMode.EAGER);
List list = criteria.list();
--------
I get in the query where statement the follow:
--------
... where A.ID_A = B.ID_A
and B.ID_C = C.ID_C
--------
This work good, but if i make a subCriteria:
--------
Criteria criteria = session.createCriteria(A.class);
criteria.setFetchMode("B", FetchMode.EAGER);
Criteria criteriaB = criteria.createCriteria("B");
List list = criteria.list();
--------
In the query i get:
--------
... where A.ID_A = B.ID_A and B.ID_C = C.ID_C
--------
I've added the "outer-join=true" setting in both "config" and mapping files.
This is correct behavior.