Top Description Fields Constructors Methods
org.eclipse.persistence.descriptors

public Class FetchGroupManager

extends Object
implements Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable
Imports
java.util.HashMap, .HashSet, .Iterator, .Map, .Set, .Vector, java.util.concurrent.ConcurrentHashMap, org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy, org.eclipse.persistence.exceptions.DescriptorException, .ValidationException, org.eclipse.persistence.internal.descriptors.ObjectBuilder, org.eclipse.persistence.internal.helper.ClassConstants, .DatabaseField, .Helper, org.eclipse.persistence.internal.queries.AttributeItem, .EntityFetchGroup, org.eclipse.persistence.internal.sessions.AbstractSession, .UnitOfWorkImpl, org.eclipse.persistence.mappings.DatabaseMapping, org.eclipse.persistence.queries.AttributeGroup, .FetchGroup, .FetchGroupTracker

Purpose: The fetch group manager controls the named fetch groups defined at the descriptor level. EclipseLink supports multiple, overlapped fetch groups, optionally with one of them as the default fetch group.

The domain object must implement org.eclipse.persistence.queries.FetchGroupTracker interface, in order to make use of the fetch group performance enhancement feature.

Please refer to FetchGroup class for the pros and cons of fetch group usage.

Author
King Wang, dclarke
Since
TopLink 10.1.3.
See Also
org.eclipse.persistence.queries.FetchGroup, org.eclipse.persistence.queries.FetchGroupTracker

Field Summary

Modifier and TypeField and Description
private EntityFetchGroup
private FetchGroup
private ClassDescriptor
private transient Map<Set<String>, EntityFetchGroup>
private Map<String, FetchGroup>
private FetchGroup
private EntityFetchGroup
private FetchGroup
private EntityFetchGroup
private boolean

Constructor Summary

AccessConstructor and Description
public
FetchGroupManager()

Constructor

Method Summary

Modifier and TypeMethod and Description
public void
addFetchGroup(FetchGroup group)

Add a named fetch group to the descriptor

public void
addMinimalFetchGroup(FetchGroup fetchGroup)

INTERNAL: Add primary key and version attributes to the passed fetch group.

public Object
clone()

Overrides java.lang.Object.clone.

INTERNAL: Clone the fetch group manager.
public void
copyAggregateFetchGroupInto(Object source, Object target, Object rootEntity, AbstractSession session)

INTERNAL: Copy fetch group reference from the source object to the target

public void
copyFetchGroupInto(Object source, Object target, AbstractSession session)

INTERNAL: Copy fetch group reference from the source object to the target

public FetchGroup
createDefaultFetchGroup()

PUBLIC: Returns clone of the default fetch group.

public FetchGroup
createFullFetchGroup()

PUBLIC: Returns clone of the full fetch group - contains all the attributes, no nesting.

public FetchGroup
createMinimalFetchGroup()

PUBLIC: Returns clone of the minimal fetch group.

public EntityFetchGroup
flatUnionFetchGroups(FetchGroup first, FetchGroup second, boolean shouldClone)

INTERNAL: Union two fetch groups as EntityFetchGroups.

public EntityFetchGroup
getDefaultEntityFetchGroup()

INTERNAL: Returns EntityFetchGroup corresponding to default FetchGroup.

public FetchGroup
getDefaultFetchGroup()

Return the descriptor-level default fetch group.

public ClassDescriptor
getDescriptor()

PUBLIC: Return the referenced descriptor.

public EntityFetchGroup
getEntityFetchGroup(Set<String> attributeNames)

INTERNAL: Returns entity fetch group corresponding to the passed set of attributes.

public EntityFetchGroup
getEntityFetchGroup(FetchGroup fetchGroup)

INTERNAL: Returns entity fetch group corresponding to the passed fetch group.

public FetchGroup
getFetchGroup(String groupName)

Return a pre-defined named fetch group.

public FetchGroup
getFetchGroup(String groupName, boolean useDefault)

Lookup the FetchGroup to use given a name and a flag taking into consideration descriptor inheritance to ensure parent descriptors are searched for named and default FetchGroup.

public Map<String, FetchGroup>
getFetchGroups()

Return the fetch group map: keyed by the group name, valued by the fetch group object.

public EntityFetchGroup
getIdEntityFetchGroup()

INTERNAL: Returns EntityFetchGroup corresponding to primary key attribute(s).

public EntityFetchGroup
getNonReferenceEntityFetchGroup()

INTERNAL: Returns EntityFetchGroup corresponding to non relational attributes intersected with defaultFetchGroup.

public EntityFetchGroup
getNonReferenceEntityFetchGroup(boolean addPk, boolean addVersion)

INTERNAL: Returns EntityFetchGroup corresponding to non relational attributes intersected with defaultFetchGroup.

public EntityFetchGroup
getObjectEntityFetchGroup(Object domainObject)

INTERNAL: Return FetchGroup held by the object.

public FetchGroup
getObjectFetchGroup(Object domainObject)

INTERNAL: Return FetchGroup held by the object.

public boolean
hasFetchGroup(String groupName)

Return true if a fetch group exists for the given group name.

public void
initialize(AbstractSession session)

INTERNAL: Initialize the fetch groups.

protected void
public boolean
isAttributeFetched(Object entity, String attributeName)

Return true if the attribute of the object has already been fetched

public boolean
isFullFetchGroup(FetchGroup fetchGroup)

PUBLIC: Indicates whether the passed fetch group contains all the attributes, no nesting.

public boolean
isMinimalFetchGroup(FetchGroup fetchGroup)

PUBLIC: Indicates whether the passed fetch group is minimal.

public boolean
isObjectValidForFetchGroup(Object object, FetchGroup fetchGroup)

INTERNAL: Return if the cached object data is sufficiently valid against a fetch group

public boolean
isPartialObject(Object domainObject)

INTERNAL: Return true if the object is partially fetched and cached.

public void
postInitialize(AbstractSession session)

INTERNAL: postInitialize called for inheritance children first.

public void
prepareAndVerify(FetchGroup fetchGroup)

PUBLIC: Add primary key and version attributes to the passed fetch group and all the fetch group it contains.

protected void
prepareAndVerifyInternal(FetchGroup fetchGroup, String attributePrefix)

INTERNAL: Add primary key and version attributes to the passed fetch group and all the fetch group it contains.

private void
refreshFetchGroupIntoClones(Object cachedObject, Object workingClone, Object backupClone, FetchGroup fetchGroupInObject, FetchGroup fetchGroupInClone, UnitOfWorkImpl uow)

INTERNAL: Refresh the fetch group data into the working and backup clones.

public void
reset(Object source)

INTERNAL: Reset object attributes to the default values.

private void
revertDataIntoUnfetchedAttributesOfClones(Object cachedObject, Object workingClone, Object backupClone, FetchGroup fetchGroupInObject, FetchGroup fetchGroupInClone, UnitOfWorkImpl uow)

Revert the clones' unfetched attributes, and leave fetched ones intact.

public void
setDefaultFetchGroup(FetchGroup newDefaultFetchGroup)

Set the descriptor-level default fetch group.

public void
setDescriptor(ClassDescriptor descriptor)

Set the referenced descriptor.

public void
setObjectFetchGroup(Object source, FetchGroup fetchGroup, AbstractSession session)

INTERNAL: Set fetch group into the object.

public void
setRefreshOnFetchGroupToObject(Object source, boolean shouldRefreshOnFetchgroup)

INTERNAL: Set if the tracked object is fetched from executing a query with or without refresh.

public void
setShouldUseInheritedDefaultFetchGroup(boolean shouldUseInheritedDefaultFetchGroup)

PUBLIC: Set whether defaultFetchGroup should be copied from the parent if not set.

public boolean
shouldUseInheritedDefaultFetchGroup()

PUBLIC: Indicates whether defaultFetchGroup should be copied from the parent if not set.

public boolean
shouldWriteInto(Object cachedObject, Object clone)

INTERNAL: Return true if the cached object data should be written in clone.

public void
unionEntityFetchGroupIntoObject(Object source, EntityFetchGroup newEntityFetchGroup, AbstractSession session, boolean shouldClone)

INTERNAL: Union the fetch group of the domain object with the new fetch group.

public FetchGroup
unionFetchGroups(FetchGroup first, FetchGroup second)

INTERNAL: Union two fetch groups.

public void
writePartialIntoClones(Object partialObject, Object workingClone, Object backupClone, UnitOfWorkImpl uow)

INTERNAL: Write data of the partially fetched object into the working and backup clones

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultEntityFetchGroupback to summary
private EntityFetchGroup defaultEntityFetchGroup
defaultFetchGroupback to summary
private FetchGroup defaultFetchGroup
descriptorback to summary
private ClassDescriptor descriptor
entityFetchGroupsback to summary
private transient Map<Set<String>, EntityFetchGroup> entityFetchGroups
fetchGroupsback to summary
private Map<String, FetchGroup> fetchGroups
fullFetchGroupback to summary
private FetchGroup fullFetchGroup
idEntityFetchGroupback to summary
private EntityFetchGroup idEntityFetchGroup
minimalFetchGroupback to summary
private FetchGroup minimalFetchGroup
nonReferenceEntityFetchGroupback to summary
private EntityFetchGroup nonReferenceEntityFetchGroup
shouldUseInheritedDefaultFetchGroupback to summary
private boolean shouldUseInheritedDefaultFetchGroup

Constructor Detail

FetchGroupManagerback to summary
public FetchGroupManager()

Constructor

Method Detail

addFetchGroupback to summary
public void addFetchGroup(FetchGroup group)

Add a named fetch group to the descriptor

addMinimalFetchGroupback to summary
public void addMinimalFetchGroup(FetchGroup fetchGroup)

INTERNAL: Add primary key and version attributes to the passed fetch group.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

INTERNAL: Clone the fetch group manager.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
copyAggregateFetchGroupIntoback to summary
public void copyAggregateFetchGroupInto(Object source, Object target, Object rootEntity, AbstractSession session)

INTERNAL: Copy fetch group reference from the source object to the target

copyFetchGroupIntoback to summary
public void copyFetchGroupInto(Object source, Object target, AbstractSession session)

INTERNAL: Copy fetch group reference from the source object to the target

createDefaultFetchGroupback to summary
public FetchGroup createDefaultFetchGroup()

PUBLIC: Returns clone of the default fetch group. Could be used as a starting point for a new user-defined fetch group.

createFullFetchGroupback to summary
public FetchGroup createFullFetchGroup()

PUBLIC: Returns clone of the full fetch group - contains all the attributes, no nesting. Could be used as a starting point for a new user-defined fetch group.

createMinimalFetchGroupback to summary
public FetchGroup createMinimalFetchGroup()

PUBLIC: Returns clone of the minimal fetch group. Could be used as a starting point for a new user-defined fetch group.

flatUnionFetchGroupsback to summary
public EntityFetchGroup flatUnionFetchGroups(FetchGroup first, FetchGroup second, boolean shouldClone)

INTERNAL: Union two fetch groups as EntityFetchGroups. Ignores all nested attributes.

getDefaultEntityFetchGroupback to summary
public EntityFetchGroup getDefaultEntityFetchGroup()

INTERNAL: Returns EntityFetchGroup corresponding to default FetchGroup.

getDefaultFetchGroupback to summary
public FetchGroup getDefaultFetchGroup()

Return the descriptor-level default fetch group. All read object and read all queries would use the default fetch group if no fetch group is explicitly defined for the query, unless setShouldUseDefaultFetchGroup(false); is also called on the query. Default fetch group should be used carefully. It would be beneficial if most of the system queries are for the subset of the object, so un-needed attributes data would not have to be read, and the users do not have to setup every query for the given fetch group, as default one is always used. However, if queries on object are mostly use case specific and not systematic, using default fetch group could cause undesirable extra round-trip and performance degradation.

See Also
org.eclipse.persistence.queries.ObjectLevelReadQuery#setShouldUseDefaultFetchGroup(boolean)
getDescriptorback to summary
public ClassDescriptor getDescriptor()

PUBLIC: Return the referenced descriptor.

getEntityFetchGroupback to summary
public EntityFetchGroup getEntityFetchGroup(Set<String> attributeNames)

INTERNAL: Returns entity fetch group corresponding to the passed set of attributes.

getEntityFetchGroupback to summary
public EntityFetchGroup getEntityFetchGroup(FetchGroup fetchGroup)

INTERNAL: Returns entity fetch group corresponding to the passed fetch group.

getFetchGroupback to summary
public FetchGroup getFetchGroup(String groupName)

Return a pre-defined named fetch group. Lookup the FetchGroup to use given a name taking into consideration descriptor inheritance to ensure parent descriptors are searched for named FetchGroups.

getFetchGroupback to summary
public FetchGroup getFetchGroup(String groupName, boolean useDefault)

Lookup the FetchGroup to use given a name and a flag taking into consideration descriptor inheritance to ensure parent descriptors are searched for named and default FetchGroup. This is used to determine the FetchGroup to use in a query's prepare.

getFetchGroupsback to summary
public Map<String, FetchGroup> getFetchGroups()

Return the fetch group map: keyed by the group name, valued by the fetch group object.

getIdEntityFetchGroupback to summary
public EntityFetchGroup getIdEntityFetchGroup()

INTERNAL: Returns EntityFetchGroup corresponding to primary key attribute(s).

getNonReferenceEntityFetchGroupback to summary
public EntityFetchGroup getNonReferenceEntityFetchGroup()

INTERNAL: Returns EntityFetchGroup corresponding to non relational attributes intersected with defaultFetchGroup.

getNonReferenceEntityFetchGroupback to summary
public EntityFetchGroup getNonReferenceEntityFetchGroup(boolean addPk, boolean addVersion)

INTERNAL: Returns EntityFetchGroup corresponding to non relational attributes intersected with defaultFetchGroup.

getObjectEntityFetchGroupback to summary
public EntityFetchGroup getObjectEntityFetchGroup(Object domainObject)

INTERNAL: Return FetchGroup held by the object.

getObjectFetchGroupback to summary
public FetchGroup getObjectFetchGroup(Object domainObject)

INTERNAL: Return FetchGroup held by the object.

hasFetchGroupback to summary
public boolean hasFetchGroup(String groupName)

Return true if a fetch group exists for the given group name.

initializeback to summary
public void initialize(AbstractSession session) throws DescriptorException

INTERNAL: Initialize the fetch groups. XXX-dclarke: added support for reinit the query manager's queries if they exist

initNonReferenceEntityFetchGroupback to summary
protected void initNonReferenceEntityFetchGroup()
isAttributeFetchedback to summary
public boolean isAttributeFetched(Object entity, String attributeName)

Return true if the attribute of the object has already been fetched

isFullFetchGroupback to summary
public boolean isFullFetchGroup(FetchGroup fetchGroup)

PUBLIC: Indicates whether the passed fetch group contains all the attributes, no nesting.

isMinimalFetchGroupback to summary
public boolean isMinimalFetchGroup(FetchGroup fetchGroup)

PUBLIC: Indicates whether the passed fetch group is minimal.

isObjectValidForFetchGroupback to summary
public boolean isObjectValidForFetchGroup(Object object, FetchGroup fetchGroup)

INTERNAL: Return if the cached object data is sufficiently valid against a fetch group

isPartialObjectback to summary
public boolean isPartialObject(Object domainObject)

INTERNAL: Return true if the object is partially fetched and cached. It applies to the query with fetch group.

postInitializeback to summary
public void postInitialize(AbstractSession session) throws DescriptorException

INTERNAL: postInitialize called for inheritance children first. That allows to copy defaultFetchGroup from the parent only in case it has been set by user (not automatically generated).

prepareAndVerifyback to summary
public void prepareAndVerify(FetchGroup fetchGroup)

PUBLIC: Add primary key and version attributes to the passed fetch group and all the fetch group it contains. Also verifies that all the attributes have corresponding mappings. Could be used for fetch group preparation and validation. Called by ObjectLevelReadQuery prepareFetchgroup method.

prepareAndVerifyInternalback to summary
protected void prepareAndVerifyInternal(FetchGroup fetchGroup, String attributePrefix)

INTERNAL: Add primary key and version attributes to the passed fetch group and all the fetch group it contains. Also verifies that all the attributes have corresponding mappings.

refreshFetchGroupIntoClonesback to summary
private void refreshFetchGroupIntoClones(Object cachedObject, Object workingClone, Object backupClone, FetchGroup fetchGroupInObject, FetchGroup fetchGroupInClone, UnitOfWorkImpl uow)

INTERNAL: Refresh the fetch group data into the working and backup clones. This is called if refresh is enforced

resetback to summary
public void reset(Object source)

INTERNAL: Reset object attributes to the default values.

revertDataIntoUnfetchedAttributesOfClonesback to summary
private void revertDataIntoUnfetchedAttributesOfClones(Object cachedObject, Object workingClone, Object backupClone, FetchGroup fetchGroupInObject, FetchGroup fetchGroupInClone, UnitOfWorkImpl uow)

Revert the clones' unfetched attributes, and leave fetched ones intact.

setDefaultFetchGroupback to summary
public void setDefaultFetchGroup(FetchGroup newDefaultFetchGroup)

Set the descriptor-level default fetch group. All read object and read all queries would use the default fetch group if no fetch group is explicitly defined for the query, unless setShouldUseDefaultFetchGroup(false); is also called on the query. Default fetch group should be used carefully. It would be beneficial if most of the system queries are for the subset of the object, so un-needed attributes data would not have to be read, and the users do not have to setup every query for the given fetch group, as default one is always used. However, if queries on object are mostly use case specific and not systematic, using default fetch group could cause undesirable extra round-trip and performance degradation.

See Also
org.eclipse.persistence.queries.ObjectLevelReadQuery#setShouldUseDefaultFetchGroup(boolean)
setDescriptorback to summary
public void setDescriptor(ClassDescriptor descriptor)

Set the referenced descriptor.

setObjectFetchGroupback to summary
public void setObjectFetchGroup(Object source, FetchGroup fetchGroup, AbstractSession session)

INTERNAL: Set fetch group into the object.

setRefreshOnFetchGroupToObjectback to summary
public void setRefreshOnFetchGroupToObject(Object source, boolean shouldRefreshOnFetchgroup)

INTERNAL: Set if the tracked object is fetched from executing a query with or without refresh.

setShouldUseInheritedDefaultFetchGroupback to summary
public void setShouldUseInheritedDefaultFetchGroup(boolean shouldUseInheritedDefaultFetchGroup)

PUBLIC: Set whether defaultFetchGroup should be copied from the parent if not set.

shouldUseInheritedDefaultFetchGroupback to summary
public boolean shouldUseInheritedDefaultFetchGroup()

PUBLIC: Indicates whether defaultFetchGroup should be copied from the parent if not set.

shouldWriteIntoback to summary
public boolean shouldWriteInto(Object cachedObject, Object clone)

INTERNAL: Return true if the cached object data should be written in clone. It is used in Fetch Group case when filling in the clone from the cached object.

unionEntityFetchGroupIntoObjectback to summary
public void unionEntityFetchGroupIntoObject(Object source, EntityFetchGroup newEntityFetchGroup, AbstractSession session, boolean shouldClone)

INTERNAL: Union the fetch group of the domain object with the new fetch group.

unionFetchGroupsback to summary
public FetchGroup unionFetchGroups(FetchGroup first, FetchGroup second)

INTERNAL: Union two fetch groups.

writePartialIntoClonesback to summary
public void writePartialIntoClones(Object partialObject, Object workingClone, Object backupClone, UnitOfWorkImpl uow)

INTERNAL: Write data of the partially fetched object into the working and backup clones