[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Dynamic FetchGroup usage

Hello.
I'm trying to use the new FetchGroup feature in EclipseLink.
Maybe I'm not understanding the API, but from what I read, I understand that
you can create a FetchGroup dynamically at the query level in an Entity Bean
without a FetchGroupManager specifically defined in the Descriptor
Customizer.

This is what my code looks like:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        if (!queryObject.getUnmodifiablePartialAttributes().isEmpty()) {
            final FetchGroup fetchGroup = new FetchGroup();
            for (String partialAttribute :
queryObject.getUnmodifiablePartialAttributes()) {
                fetchGroup.addAttribute(partialAttribute);
            }
            readAllQuery.setFetchGroup(fetchGroup);
        }
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

When I run the application, I get the following
org.eclipse.persistence.exceptions.QueryException:
"You must define a fetch group manager at descriptor (...) in order to set a
fetch group on the query (...)"

Debugging the code I see the following in ObjectLevelReadQuery.java
(2015-2043):
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    public void prepareFetchGroup() throws QueryException {
        FetchGroupManager fetchGroupManager =
this.descriptor.getFetchGroupManager();
        if (fetchGroupManager != null) {
            if(this.fetchGroup == null) {
                if(this.fetchGroupName != null) {
                    this.fetchGroup =
fetchGroupManager.getFetchGroup(this.fetchGroupName);
                }
            }
            // that may be either fetchGroup or defaultFetchGroup from
descriptor
            FetchGroup executionFetchGroup = getExecutionFetchGroup();
            if(executionFetchGroup != null) {
                if (hasPartialAttributeExpressions()) {
                    //fetch group does not work with partial attribute
reading
                    throw
QueryException.fetchGroupNotSupportOnPartialAttributeReading();
                }
                if(this.fetchGroup != null) {
                   
this.descriptor.getFetchGroupManager().prepareAndVerify(this.fetchGroup);
                    this.entityFetchGroup =
fetchGroupManager.getEntityFetchGroup(this.fetchGroup);
                } else {
                    this.entityFetchGroup = null;
                }
            }
        } else {
            // FetchGroupManager is null
            if(this.fetchGroup != null || this.fetchGroupName != null) {
                throw
QueryException.fetchGroupValidOnlyIfFetchGroupManagerInDescriptor(getDescriptor().getJavaClassName(),
getName());
            }
        }
    }
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

From this code I understand that a FetchGroupManager would be specified in
the class descriptor, but that isn't what I expect from the API.

Is this a BUG or should I specify a fetchgroupmanager for all the classes I
expect to use a dynamic fetchgroup?

Regards
--
Marc Nuri
-- 
View this message in context: http://old.nabble.com/Dynamic-FetchGroup-usage-tp30328424p30328424.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.