-->
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.  [ 3 posts ] 
Author Message
 Post subject: Criteria API supports nested eager fetching?
PostPosted: Tue Feb 24, 2004 10:37 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
I'm working with HB 2.1.2.

My question/request has to do with setting the fetch-mode when using the criteria API.

It seems like you can't declare eager fetches for nested associations:
Code:
Criteria criteria = session.createCriteria(Person.class);

criteria.createCriteria("entityLocation")
  .add( Expression.eq("id", locationId) )
  .setFetchMode( "entity", FetchMode.EAGER);


From my testing, it seems this will not do an eager fetch for the EntityLocation.entity association (the setFetchMode() doesn't fail, just seems to be ignored).

Am I wrong, or does the criteria API not yet support this?
Any problem with my creating a JIRA to request this functionality?

I can workaround the issue in my app by modelling the EntityLocation.entity association with outer-join="true", but it seems like this is a necessary feature.

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject: Re: Criteria API supports nested eager fetching?
PostPosted: Wed Feb 25, 2004 7:22 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
stolley wrote:
I'm working with HB 2.1.2.

My question/request has to do with setting the fetch-mode when using the criteria API....


Criteria API doesn't support setting eagger fetching for subcriterias.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2004 8:20 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Quote:
Criteria API doesn't support setting eager fetching for subcriterias

Sorry, bad example, it doesn't just have to be subcriterias.

When you're displaying the results of a search, it's quite likely that you're going to need attributes from associated objects, whether you restrict on those associations or not. That's why Criteria API eager fetching functionality exists in the first place, right?

The problem is, if your domain model is fine grained, it's inevitable that you'll need to navigate more than one association deep to get the data to display in the result list of your search.

So, I'm not asking specifically for eager fetching of associations off of subcriterias, I'm asking for eager fetching off of any association.

The example code I gave is severely cut down. The actual subcriteria on entityLocation is optional. If that subcriteria is not added, I still need to eager fetch the entityLocation association (which is easy), but I also still need to eager fetch the entity association off of the EntityLocation objects (seems to be impossible?)

_________________
Cheers,
Shorn.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.