Class FetchGroupManager
java.lang.Object
org.eclipse.persistence.descriptors.FetchGroupManager
- All Implemented Interfaces:
Serializable,Cloneable
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.
- See Also:
- Author:
- King Wang, dclarke
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFetchGroup(FetchGroup group) Add a named fetch group to the descriptorvoidaddMinimalFetchGroup(FetchGroup fetchGroup) INTERNAL: Add primary key and version attributes to the passed fetch group.clone()INTERNAL: Clone the fetch group manager.voidcopyAggregateFetchGroupInto(Object source, Object target, Object rootEntity, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Copy fetch group reference from the source object to the targetvoidcopyFetchGroupInto(Object source, Object target, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Copy fetch group reference from the source object to the targetPUBLIC: Returns clone of the default fetch group.PUBLIC: Returns clone of the full fetch group - contains all the attributes, no nesting.PUBLIC: Returns clone of the minimal fetch group.org.eclipse.persistence.internal.queries.EntityFetchGroupflatUnionFetchGroups(FetchGroup first, FetchGroup second, boolean shouldClone) INTERNAL: Union two fetch groups as EntityFetchGroups.org.eclipse.persistence.internal.queries.EntityFetchGroupINTERNAL: Returns EntityFetchGroup corresponding to default FetchGroup.Return the descriptor-level default fetch group.PUBLIC: Return the referenced descriptor.org.eclipse.persistence.internal.queries.EntityFetchGroupgetEntityFetchGroup(Set<String> attributeNames) INTERNAL: Returns entity fetch group corresponding to the passed set of attributes.org.eclipse.persistence.internal.queries.EntityFetchGroupgetEntityFetchGroup(FetchGroup fetchGroup) INTERNAL: Returns entity fetch group corresponding to the passed fetch group.getFetchGroup(String groupName) Return a pre-defined named fetch group.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.Return the fetch group map: keyed by the group name, valued by the fetch group object.org.eclipse.persistence.internal.queries.EntityFetchGroupINTERNAL: Returns EntityFetchGroup corresponding to primary key attribute(s).org.eclipse.persistence.internal.queries.EntityFetchGroupINTERNAL: Returns EntityFetchGroup corresponding to non relational attributes intersected with defaultFetchGroup.org.eclipse.persistence.internal.queries.EntityFetchGroupgetNonReferenceEntityFetchGroup(boolean addPk, boolean addVersion) INTERNAL: Returns EntityFetchGroup corresponding to non relational attributes intersected with defaultFetchGroup.org.eclipse.persistence.internal.queries.EntityFetchGroupgetObjectEntityFetchGroup(Object domainObject) INTERNAL: Return FetchGroup held by the object.getObjectFetchGroup(Object domainObject) INTERNAL: Return FetchGroup held by the object.booleanhasFetchGroup(String groupName) Return true if a fetch group exists for the given group name.voidinitialize(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Initialize the fetch groups.protected voidbooleanisAttributeFetched(Object entity, String attributeName) Return true if the attribute of the object has already been fetchedbooleanisFullFetchGroup(FetchGroup fetchGroup) PUBLIC: Indicates whether the passed fetch group contains all the attributes, no nesting.booleanisMinimalFetchGroup(FetchGroup fetchGroup) PUBLIC: Indicates whether the passed fetch group is minimal.booleanisObjectValidForFetchGroup(Object object, FetchGroup fetchGroup) INTERNAL: Return if the cached object data is sufficiently valid against a fetch groupbooleanisPartialObject(Object domainObject) INTERNAL: Return true if the object is partially fetched and cached.voidpostInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: postInitialize called for inheritance children first.voidprepareAndVerify(FetchGroup fetchGroup) PUBLIC: Add primary key and version attributes to the passed fetch group and all the fetch group it contains.protected voidprepareAndVerifyInternal(FetchGroup fetchGroup, String attributePrefix) INTERNAL: Add primary key and version attributes to the passed fetch group and all the fetch group it contains.voidINTERNAL: Reset object attributes to the default values.voidsetDefaultFetchGroup(FetchGroup newDefaultFetchGroup) Set the descriptor-level default fetch group.voidsetDescriptor(ClassDescriptor descriptor) Set the referenced descriptor.voidsetObjectFetchGroup(Object source, FetchGroup fetchGroup, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Set fetch group into the object.voidsetRefreshOnFetchGroupToObject(Object source, boolean shouldRefreshOnFetchgroup) INTERNAL: Set if the tracked object is fetched from executing a query with or without refresh.voidsetShouldUseInheritedDefaultFetchGroup(boolean shouldUseInheritedDefaultFetchGroup) PUBLIC: Set whether defaultFetchGroup should be copied from the parent if not set.booleanPUBLIC: Indicates whether defaultFetchGroup should be copied from the parent if not set.booleanshouldWriteInto(Object cachedObject, Object clone) INTERNAL: Return true if the cached object data should be written in clone.voidunionEntityFetchGroupIntoObject(Object source, org.eclipse.persistence.internal.queries.EntityFetchGroup newEntityFetchGroup, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean shouldClone) INTERNAL: Union the fetch group of the domain object with the new fetch group.unionFetchGroups(FetchGroup first, FetchGroup second) INTERNAL: Union two fetch groups.voidwritePartialIntoClones(Object partialObject, Object workingClone, Object backupClone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow) INTERNAL: Write data of the partially fetched object into the working and backup clones
-
Constructor Details
-
FetchGroupManager
public FetchGroupManager()Constructor
-
-
Method Details
-
addFetchGroup
Add a named fetch group to the descriptor -
getFetchGroups
Return the fetch group map: keyed by the group name, valued by the fetch group object. -
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. -
getDefaultEntityFetchGroup
public org.eclipse.persistence.internal.queries.EntityFetchGroup getDefaultEntityFetchGroup()INTERNAL: Returns EntityFetchGroup corresponding to default FetchGroup. -
createMinimalFetchGroup
PUBLIC: Returns clone of the minimal fetch group. Could be used as a starting point for a new user-defined fetch group. -
isMinimalFetchGroup
PUBLIC: Indicates whether the passed fetch group is minimal. -
getIdEntityFetchGroup
public org.eclipse.persistence.internal.queries.EntityFetchGroup getIdEntityFetchGroup()INTERNAL: Returns EntityFetchGroup corresponding to primary key attribute(s). -
getNonReferenceEntityFetchGroup
public org.eclipse.persistence.internal.queries.EntityFetchGroup getNonReferenceEntityFetchGroup()INTERNAL: Returns EntityFetchGroup corresponding to non relational attributes intersected with defaultFetchGroup. -
getNonReferenceEntityFetchGroup
public org.eclipse.persistence.internal.queries.EntityFetchGroup getNonReferenceEntityFetchGroup(boolean addPk, boolean addVersion) INTERNAL: Returns EntityFetchGroup corresponding to non relational attributes intersected with defaultFetchGroup. -
addMinimalFetchGroup
INTERNAL: Add primary key and version attributes to the passed fetch group. -
prepareAndVerify
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. -
prepareAndVerifyInternal
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. -
createDefaultFetchGroup
PUBLIC: Returns clone of the default fetch group. Could be used as a starting point for a new user-defined fetch group. -
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. -
isFullFetchGroup
PUBLIC: Indicates whether the passed fetch group contains all the attributes, no nesting. -
getEntityFetchGroup
public org.eclipse.persistence.internal.queries.EntityFetchGroup getEntityFetchGroup(Set<String> attributeNames) INTERNAL: Returns entity fetch group corresponding to the passed set of attributes. -
getEntityFetchGroup
public org.eclipse.persistence.internal.queries.EntityFetchGroup getEntityFetchGroup(FetchGroup fetchGroup) INTERNAL: Returns entity fetch group corresponding to the passed fetch group. -
getFetchGroup
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. -
getFetchGroup
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. -
setDefaultFetchGroup
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. -
isPartialObject
INTERNAL: Return true if the object is partially fetched and cached. It applies to the query with fetch group. -
isObjectValidForFetchGroup
INTERNAL: Return if the cached object data is sufficiently valid against a fetch group -
shouldWriteInto
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. -
writePartialIntoClones
public void writePartialIntoClones(Object partialObject, Object workingClone, Object backupClone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow) INTERNAL: Write data of the partially fetched object into the working and backup clones -
copyAggregateFetchGroupInto
public void copyAggregateFetchGroupInto(Object source, Object target, Object rootEntity, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Copy fetch group reference from the source object to the target -
copyFetchGroupInto
public void copyFetchGroupInto(Object source, Object target, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Copy fetch group reference from the source object to the target -
unionEntityFetchGroupIntoObject
public void unionEntityFetchGroupIntoObject(Object source, org.eclipse.persistence.internal.queries.EntityFetchGroup newEntityFetchGroup, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean shouldClone) INTERNAL: Union the fetch group of the domain object with the new fetch group. -
unionFetchGroups
INTERNAL: Union two fetch groups. -
flatUnionFetchGroups
public org.eclipse.persistence.internal.queries.EntityFetchGroup flatUnionFetchGroups(FetchGroup first, FetchGroup second, boolean shouldClone) INTERNAL: Union two fetch groups as EntityFetchGroups. Ignores all nested attributes. -
reset
INTERNAL: Reset object attributes to the default values. -
getObjectFetchGroup
INTERNAL: Return FetchGroup held by the object. -
getObjectEntityFetchGroup
public org.eclipse.persistence.internal.queries.EntityFetchGroup getObjectEntityFetchGroup(Object domainObject) INTERNAL: Return FetchGroup held by the object. -
setObjectFetchGroup
public void setObjectFetchGroup(Object source, FetchGroup fetchGroup, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Set fetch group into the object. -
setRefreshOnFetchGroupToObject
INTERNAL: Set if the tracked object is fetched from executing a query with or without refresh. -
isAttributeFetched
Return true if the attribute of the object has already been fetched -
getDescriptor
PUBLIC: Return the referenced descriptor. -
setDescriptor
Set the referenced descriptor. -
hasFetchGroup
Return true if a fetch group exists for the given group name. -
initialize
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException INTERNAL: Initialize the fetch groups. XXX-dclarke: added support for reinit the query manager's queries if they exist- Throws:
DescriptorException
-
postInitialize
public void postInitialize(org.eclipse.persistence.internal.sessions.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).- Throws:
DescriptorException
-
initNonReferenceEntityFetchGroup
protected void initNonReferenceEntityFetchGroup() -
clone
INTERNAL: Clone the fetch group manager. -
setShouldUseInheritedDefaultFetchGroup
public void setShouldUseInheritedDefaultFetchGroup(boolean shouldUseInheritedDefaultFetchGroup) PUBLIC: Set whether defaultFetchGroup should be copied from the parent if not set. -
shouldUseInheritedDefaultFetchGroup
public boolean shouldUseInheritedDefaultFetchGroup()PUBLIC: Indicates whether defaultFetchGroup should be copied from the parent if not set.
-