-->
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.  [ 7 posts ] 
Author Message
 Post subject: FetchMode.SELECT has no effect
PostPosted: Thu Nov 10, 2005 6:03 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
Hibernate version:
3.0.5 & 3.1rc2

Code between sessionFactory.openSession() and session.close():
Code:
Criteria criteria = session.createCriteria(Customer.class);
criteria.add(Restrictions.idEq(id));
criteria.setFetchMode("orders", FetchMode.SELECT); // has no effect
Customer customer = (Customer)criteria.uniqueResult();


I would expect that all Orders of the Customer are "eagerly" fetched in a second select. But it makes no difference, if FetchMode.SELECT is set or not.

A possible workaround is executing either Hibernate.initialize(customer.getOrders()) or customer.getOrders().size() but this is not practical for more complex graphs.

The same query also works fine with a FetchMode.JOIN.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 12, 2005 6:39 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
Maybe my topic was a little unclear -- I'll add a simple question:

Has anybody here used FetchMode.SELECT successfully on Criteria-Queries?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 1:55 pm 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
Nobody?

Could someone from the Hibernate Team please write a comment, or should I attach a complete test case first (It's very basic....) ?

Thanks.


Top
 Profile  
 
 Post subject: So we need another FetchMode?
PostPosted: Tue Dec 06, 2005 1:28 pm 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
I'll continue my monologue...

In the meantime, I got it. The javadoc comment of FetchMode.SELECT ("Fetch eagerly, using a separate select.") is obviously misleading. The reference docs state the opposite logic.

But I still think there should be a FetchMode for immediate fetching associations mapped as lazy - without using FetchMode.JOIN.

Is there any chance for a Feature Request?


Feel free to answer me - you could earn a credit.

:)


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 4:36 am 
Newbie

Joined: Thu Oct 21, 2004 11:24 am
Posts: 3
hi,

I encounter the same problem as you are.
I see no effect to the FetchMode.LAZY (more than lazy fetch), I don't understand the comment which states that it's a eager fetch...
I would be glad to have an answer from the hibernate team.

cheers,

eric


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 2:27 pm 
Beginner
Beginner

Joined: Wed Jun 15, 2005 1:28 pm
Posts: 39
Location: United States
We're looking for the same functionality - loading an association's collection through an immediate select. So far we have not found a way to do it with the Criteria query. Using an outer join doesn't work for us because it breaks paging...


Top
 Profile  
 
 Post subject: Itz a closed Bug in JIRA
PostPosted: Tue Nov 21, 2006 6:09 am 
Newbie

Joined: Mon Feb 27, 2006 2:58 am
Posts: 10
http://opensource.atlassian.com/project ... e/HHH-1211

~Ganesh


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

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.