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

Fetch groups require that the classes were weaved for fetch groups.  This is
weaved by default, but not if you have weaving disabled, such as not using
the agent.  When the class is not weaved, the FetchGroupManager is not set.

Ensure you have weaving enabled.



MarcNuri wrote:
> 
> 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
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/Dynamic-FetchGroup-usage-tp30328424p30349836.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.