Can I perform a Criteria query with Sub-Select AND Left-Outer join?
For example, I have A 1-many B 1-many C.
With Criteria.createAlias ("b", "b", Criteria.LEFT_JOIN) I can perform Left Outer join.
With Criteria.setFetchMode ("b", org.hibernate.FetchMode.DEFAULT) I can perform Join with the default fetching strategy. I assume that having set @org.hibernate.annotations.FetchMode.SUBSELECT in both A.B and B.C is enough (is it?).
Question 1: Why does org.hibernate.FetchMode not have SUBSELECT option, whereas the org.hibernate.annotations.FetchMode does?
Question 2: Can I perform a Criteria query with Sub-Select AND Left-Outer join?
-
wouldn't the result of a left outer join(a -> b) be the same as left outer join(a -> b -> c)?fasseg– fasseg2010年04月16日 17:20:33 +00:00Commented Apr 16, 2010 at 17:20
2 Answers 2
Criteria and org.hibernate.FetchMode.SELECT does nothing. The only option for Criteria is org.hibernate.FetchMode.JOIN. I do lazy initialization for Criteria results manually:
for (Entity e : result) {
Hibernate.initizalize(e.getProperty());
}
Comments
org.hibernate.FetchMode has the same option under a different name, SELECT.