EclipseLink 2.1.0, build 'v20100529-r7411' API Reference

org.eclipse.persistence.queries
Class FetchGroup

java.lang.Object
  extended by org.eclipse.persistence.queries.AttributeGroup
      extended by org.eclipse.persistence.queries.FetchGroup
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class FetchGroup
extends AttributeGroup

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.

EclipseLink fetch group support is twofold: the pre-defined fetch groups at the descriptor level; and dynamic (use case) fetch groups at the query level.

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 Also:
FetchGroup, FetchGroupTracker, Serialized Form
Author:
King Wang, dclarke
Since:
TopLink 10.1.3.

Field Summary
 
Fields inherited from class org.eclipse.persistence.queries.AttributeGroup
items
 
Constructor Summary
FetchGroup()
           
FetchGroup(java.lang.String name)
           
 
Method Summary
 FetchGroup clone()
           
 java.util.Set<java.lang.String> getAttributes()
          Deprecated. 
 FetchGroup getGroup(java.lang.String attributeNameOrPath)
          Returns FetchGroup corresponding to the passed (possibly nested) attribute.
 boolean isEntityFetchGroup()
           
 boolean isFetchGroup()
           
 FetchGroup newGroup(java.lang.String name, AttributeGroup parent)
           
 java.lang.String onUnfetchedAttribute(FetchGroupTracker entity, java.lang.String attributeName)
          INTERNAL: Called on attempt to get value of an attribute that hasn't been fetched yet.
 java.lang.String onUnfetchedAttributeForSet(FetchGroupTracker entity, java.lang.String attributeName)
          INTERNAL: Called on attempt to assign value to an attribute that hasn't been fetched yet.
 void setShouldLoad(boolean shouldLoad)
           
 void setShouldLoadAll(boolean shouldLoad)
           
 boolean shouldLoad()
           
 LoadGroup toLoadGroupLoadOnly()
           
 
Methods inherited from class org.eclipse.persistence.queries.AttributeGroup
addAttribute, addAttribute, addAttributes, containsAttribute, convert, equals, getAttributeNames, getItem, getItems, getName, hasItems, isLoadGroup, isSupersetOf, newItem, removeAttribute, setAttributeNames, setName, toFetchGroup, toLoadGroup, toString, toStringAdditionalInfo, toStringItems, toStringPath
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FetchGroup

public FetchGroup()

FetchGroup

public FetchGroup(java.lang.String name)
Method Detail

getAttributes

@Deprecated
public java.util.Set<java.lang.String> getAttributes()
Deprecated. 

Return the attribute names on the current FetchGroup. This does not include the attributes on nested FetchGroups


onUnfetchedAttribute

public java.lang.String onUnfetchedAttribute(FetchGroupTracker entity,
                                             java.lang.String attributeName)
INTERNAL: Called on attempt to get value of an attribute that hasn't been fetched yet. Returns an error message in case javax.persistence.EntityNotFoundException should be thrown by the calling method, null otherwise.


onUnfetchedAttributeForSet

public java.lang.String onUnfetchedAttributeForSet(FetchGroupTracker entity,
                                                   java.lang.String attributeName)
INTERNAL: Called on attempt to assign value to an attribute that hasn't been fetched yet. Returns an error message in case javax.persistence.EntityNotFoundException should be thrown by the calling method, null otherwise.


setShouldLoad

public void setShouldLoad(boolean shouldLoad)

setShouldLoadAll

public void setShouldLoadAll(boolean shouldLoad)

shouldLoad

public boolean shouldLoad()

newGroup

public FetchGroup newGroup(java.lang.String name,
                           AttributeGroup parent)
Overrides:
newGroup in class AttributeGroup

isFetchGroup

public boolean isFetchGroup()
Overrides:
isFetchGroup in class AttributeGroup

isEntityFetchGroup

public boolean isEntityFetchGroup()

toLoadGroupLoadOnly

public LoadGroup toLoadGroupLoadOnly()

clone

public FetchGroup clone()
Overrides:
clone in class AttributeGroup

getGroup

public FetchGroup getGroup(java.lang.String attributeNameOrPath)
Returns FetchGroup corresponding to the passed (possibly nested) attribute.

Overrides:
getGroup in class AttributeGroup

EclipseLink 2.1.0, build 'v20100529-r7411' API Reference