-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: setFetchMode and createAlias in the same association.
PostPosted: Tue Sep 25, 2012 3:47 pm 
Newbie

Joined: Tue Sep 25, 2012 3:06 pm
Posts: 1
Hi Guys,

When I use the setFetchMode in a LAZY association, the hibernate generate the
select with LEFT_OUTER_JOIN join strategy and return the expected data (the collection is loaded).

If I use the setFetchMode in a LAZY association and I create an alias in same
association forcing the INNER_JOIN, the select will be generated using the INNER_JOIN,
but the collection will not loaded.

Code:
...
Criteria c = session.createCriteria(Client.class);
c.createAlias("contact", "c");
c.setFetchMode("contact", FetchMode.JOIN);
c.add(Restrictions.eq("c.name", "Paul"));
...


In this case, the query will be filtered by contact name, but the collection will be not loaded.

The hibernate loads the collection only if the join strategy is equals LEFT_OUTER_JOIN, Why?

Debuging the hibernate code, I saw that the select is running as expected, but
there is a condition (JoinWalker.java:885) that load the collection only if the join
strategy is equals LEFT_OUTER_JOIN.

* Hibernate 3.3.2 and 3.6.10

Tks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.