FileDocCategorySizeDatePackage
FetchGroup.javaAPI DocGlassfish v2 API6669Tue May 22 16:54:50 BST 2007oracle.toplink.essentials.queryframework

FetchGroup

public class FetchGroup extends Object implements Serializable

Purpose: A fetch group is a performance enhancement that allows a group of attributes of an object to be loaded on demand, which means that the data for an attribute might not loaded from the underlying data source until an explicit access call for the attribute first occurs. It avoids the wasteful practice of loading up all data of the object?s attributes, in which the user is interested in only partial of them. A great deal of caution and careful system use case analysis should be use when using the fetch group feature, as the extra round-trip would well offset the gain from the deferred loading in many cases. TopLink fetch group support is twofold: the pre-defined fetch groups at the descriptor level; and dynamic (use case) fetch groups at the query level. TopLink fetch group support is only on CMP project. Every query can has at most one fetch group. There is an optional pre-defined default fetch group at the descriptor level. If set, and the query has no fetch group being set, the default fetch group would be used, unless query.setShouldUseDefaultFetchGroup(false) is also called. In the latter case, the full object will be fetched after the query execution.

see
oracle.toplink.essentials.queryframework.FetchGroup
see
oracle.toplink.essentials.queryframework.FetchGroupTracker
author
King Wang
since
TopLink 10.1.3.

Fields Summary
private String
name
private Set
attributes
private List
fetchGroupAttributeExpressions
Constructors Summary
public FetchGroup()
Constructor.


          
      
        this("");
    
public FetchGroup(String name)
Constructor with a group name.

        this.name = name;
        this.fetchGroupAttributeExpressions = new ArrayList();
    
Methods Summary
public voidaddAttribute(java.lang.String attrName)
Add an attribute to the group

        attributes.add(attrName);
    
public voidaddAttributes(java.util.Set newAttributes)
Add a set of attributes to the group

        attributes.addAll(newAttributes);
    
public voidaddFetchGroupAttribute(oracle.toplink.essentials.expressions.Expression attributeExpression)
INTERNAL: Specify that only a subset of the class' attributes be fetched in this query.

This allows for the query to be optimized through selecting less data.

Partial objects will be returned from the query, where the unspecified attributes will be left in their default value. The primary key, and optimistic locking version (version or timestamp) if defined, will always be fetched. The partial object is cached and can be modified. An access through getter to an un-fetched attribute will trigger another SELECT to load the whole object.

Note: Modifying un-fetched attribute is not supported and exception would thrown.

        getFetchGroupAttributeExpressions().add(attributeExpression);
    
public java.util.SetgetAttributes()
Return all attributes defined in the group

        return attributes;
    
public java.util.ListgetFetchGroupAttributeExpressions()
INTERNAL: Return the attibute expression list.

        return fetchGroupAttributeExpressions;
    
public java.lang.StringgetName()
Return the group name

        return name;
    
public booleanhasFetchGroupAttributeExpressions()
INTERNAL: Return if fetch group attributes.

        return !fetchGroupAttributeExpressions.isEmpty();
    
public booleanisSupersetOf(oracle.toplink.essentials.queryframework.FetchGroup anotherGroup)
INTERNAL: Return true if this fetch group is a super-set of the passed in fetch group

        return (anotherGroup != null) && getAttributes().containsAll(anotherGroup.getAttributes());
    
public voidremoveAttribute(java.lang.String attrName)
Remove an attribute from the group

        attributes.remove(attrName);
    
public voidsetFetchGroupAttributeExpressions(java.util.List fetchGroupAttributeExpressions)
INTERNAL: Set the attibute expression list.

        this.fetchGroupAttributeExpressions = fetchGroupAttributeExpressions;
    
public voidsetName(java.lang.String name)
Set the group name

        this.name = name;