Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Fetch Groups

Hi Doug,
    does that mean if Employee has an InsurancePolicy association which would by definition of the entity eagerly loaded, then when I write:
 
 Query query = em.createQuery("SELECT e FROM Employee e WHERE e.gender = :GENDER");
query.setParameter("GENDER", Gender.Male);

// Define the fields to be fetched on Employee
FetchGroup empGroup = new FetchGroup();
empGroup.addAttribute("firstName");
empGroup.addAttribute("lastName");
empGroup.addAttribute("address");
 
// Define the fields to be fetched on Address
FetchGroup addressGroup = new FetchGroup();
addressGroup.addAttribute("city");
addressGroup.addAttribute("postalCode");
// Configure the dynamic FetchGroup
query.setHint(QueryHints.FETCH_GROUP, empGroup);
 
List<Employee> emps = query.getResultList();
 
would I also get employeeObject.getInsurancePolicy() ?
 
This should not happen since I only queried for a few fields of employee and a few fields of its address association but not for InsurancePolicy.
 
I think only the queried fields should be populated even if the queried entity has eager associations!
 
Also, it would be better to load the properties even from lazy assocaitions when queried using fetch group.
 
I believe a better option would be to take an additional parameter on every FetchGroup object that would indicae whether a fetch group should be eagerly loaded or lazily loaded. This would help in having some fetch groups eagerly loaded and some lazilily loaded in the same query.
 
Further, if I understand it correctly,  setting 'null' for 1:m relations will fetch the entire enities in case of many valued associations.
 
Isn't there any way to fetch individual peoperties even for many valued references ?
 
Thanks and Regards,
Samba

On Tue, Sep 15, 2009 at 7:23 PM, Douglas Clarke <DOUGLAS.CLARKE@xxxxxxxxxx> wrote:
Mathias,

I was working through the setup of the next incubator when I realized the issue. I need to document this on the wiki page under known limitations of the extension.

The extension leverages a session event listener to configure secondary queries that will be lazily invoked after the query result is returned. This means that any related objects that are either forced to be loaded using JOIN FETCH or those loaded because they are not LAZY will not have their nested fetch-group applied. They will instead rely solely on the default fetch-group for the entity type.

When we move this functionality from the incubator into the main code we should be better able to address this issue.

Doug

-----Original Message-----
From: Douglas Clarke
Sent: Monday, September 14, 2009 3:50 PM
To: mathias.walter@xxxxxxx
Cc: EclipseLink User Discussions
Subject: RE: [eclipselink-users] Fetch Groups


Mathias,

I am in the process of converting this example over to be part of the Extensions Incubator (http://wiki.eclipse.org/EclipseLink/Development/Incubator/Extensions) as it is much more of an extension to the framework then an example of how to use EclipseLink. The initial check-in of the extension with the supporting test cases are available in the subversion repository.

The details are covered in the wiki @ http://wiki.eclipse.org/EclipseLink/Development/Incubator/Extensions/NestedFetchGroup

If you can provide test cases and or suggested modifications to the incubator I would be happy  to work with you to evolve the solution. Make sure you attach any contributions to the bug tracking the incubator.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=273057

Doug



-----Original Message-----
From: Mathias Walter [mailto:
Sent: Tuesday, September 08, 2009 11:37 AM
To: Douglas Clarke
Subject: RE: [eclipselink-users] Fetch Groups


Hi Douglas,

I heavily tested NestedFetchGroupTests and it also works with batch reading
(e. g. query.setHint(QueryHints.BATCH, "e.address");)
Unfortunately, it doesn't work with fetch reading
(query.setHint(QueryHints.FETCH, "e.address");
With fetch reading, the attributes of employee are fetched correctly, but
all attributes of address are fetched. Thus nested fetching does not work in
this case.
I'd like to address this issue and like to know where to start.

--
Kind regards,
Mathias

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top