1

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?

asked Apr 16, 2010 at 16:54
1
  • wouldn't the result of a left outer join(a -> b) be the same as left outer join(a -> b -> c)? Commented Apr 16, 2010 at 17:20

2 Answers 2

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());
}
answered Aug 9, 2010 at 13:40
Sign up to request clarification or add additional context in comments.

Comments

0

org.hibernate.FetchMode has the same option under a different name, SELECT.

answered Apr 16, 2010 at 19:10

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.