Package org.datanucleus
Class FetchPlan
java.lang.Object
org.datanucleus.FetchPlan
- All Implemented Interfaces:
Serializable
FetchPlan for fields for use internally.
A FetchPlan has a series of FetchPlanForClass objects being the fetch plan for particular classes.
Each FetchPlanForClass defines a series of fields of that class that are part of the fetch plan.
There are two types of fetch groups under consideration here.
- Static fetch groups, defined in MetaData (XML/Annotations).
- Dynamic fetch groups, defined via an API.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Constant defining all fields(package private) final ClassLoaderResolver
ClassLoader resolver.static final String
Constant defining the fields in the default fetch group.static final int
Members that are not loaded but are in the current fetch plan should be loaded before detachment.static final int
Members that are loaded but not in current fetch plan should be unloaded before detachment.(package private) int
Options to be used during detachment.(package private) Class[]
The classes used as the roots for detachment (DetachAllOnCommit).(package private) Collection
<Object> The instances used as the roots for detachment (DetachAllOnCommit).(package private) Set
<FetchGroup> The "dynamic" fetch groups in the current FetchPlan.(package private) final ExecutionContext
Execution Context that this FetchPlan relates to.static final int
Fetch size to load all possible.static final int
Fetch size for the implementation to decide how many to load.(package private) final Map
<String, FetchPlanForClass> FetchPlanForClass keyed by the class name.(package private) int
The Fetch size.Names of the "defined" fetch groups in the current FetchPlan.private Map
<AbstractClassMetaData, Map<BitSet, Boolean>> Cache the result of FetchPlanImpl.isToCallPostLoadFetchPlan(): for a given set of loaded members of a certain class.(package private) int
Maximum depth to fetch from the root object.static final String
Constant defing no fields.static final int
static final int
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
addDynamicGroup
(String grpName) Convenience method to add dynamic fetch groups for the specified name.Method to add a group to the fetch plan.(package private) void
cacheIsToCallPostLoadFetchPlan
(AbstractClassMetaData cmd, BitSet loadedFields, Boolean itcplfp) private void
Convenience method to clear all dynamic groups.Method to clear the current groups and activate the DFG.(package private) Boolean
getCachedIsToCallPostLoadFetchPlan
(AbstractClassMetaData cmd, BitSet loadedFields) getCopy()
Returns a copy of this FetchPlan with all settings initialized.int
Return the options to be used at detachment.Class[]
Accessor for the root classes of the detachment graph for DetachAllOnCommit.Accessor for the roots of the detachment graph for DetachAllOnCommit.Access the fetch plan for the class.int
Accessor for the fetch size when using large result sets.Accessor for the static groups for this FetchPlan.int
Accessor for the maximum fetch depth.(package private) void
private void
Mark all managed fetch plans to be dirty, so the active members need to be recomputed.void
notifyFetchGroupChange
(FetchGroup group) Method to notify this FetchPlan that the specified FetchGroup has been updated.void
notifyFetchGroupRemove
(FetchGroup group) Method to notify this FetchPlan that the specified FetchGroup has been updated.removeGroup
(String grpName) Method to remove a group from the fetch plan.(package private) void
Method called at commit() to clear out the detachment roots.setDetachmentOptions
(int options) Set the options to be used at detachment.setDetachmentRootClasses
(Class[] rootClasses) Set the classes used for roots of the detachment graph for DetachAllOnCommit.setDetachmentRoots
(Collection<Object> roots) Set the roots for DetachAllOnCommitsetFetchSize
(int fetchSize) Method to set the fetch size when using large result sets.Method to set the fetch group.Method to set the groups using an array.setGroups
(Collection<String> grpNames) Method to set the groups of the fetch plan.setMaxFetchDepth
(int max) Mutator for the maximum fetch depth where -1 implies no restriction on the fetch depth.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
DEFAULT
Constant defining the fields in the default fetch group.- See Also:
-
ALL
Constant defining all fields- See Also:
-
NONE
Constant defing no fields.- See Also:
-
DETACH_UNLOAD_FIELDS
public static final int DETACH_UNLOAD_FIELDSMembers that are loaded but not in current fetch plan should be unloaded before detachment.- See Also:
-
DETACH_LOAD_FIELDS
public static final int DETACH_LOAD_FIELDSMembers that are not loaded but are in the current fetch plan should be loaded before detachment.- See Also:
-
FETCH_SIZE_GREEDY
public static final int FETCH_SIZE_GREEDYFetch size to load all possible.- See Also:
-
FETCH_SIZE_OPTIMAL
public static final int FETCH_SIZE_OPTIMALFetch size for the implementation to decide how many to load.- See Also:
-
RECURSION_DEPTH_UNLIMITED
public static final int RECURSION_DEPTH_UNLIMITED- See Also:
-
RECURSION_DEPTH_FK_ONLY
public static final int RECURSION_DEPTH_FK_ONLY- See Also:
-
ec
Execution Context that this FetchPlan relates to. -
clr
ClassLoader resolver. -
groupNames
Names of the "defined" fetch groups in the current FetchPlan. -
dynamicGroups
The "dynamic" fetch groups in the current FetchPlan. -
fetchSize
int fetchSizeThe Fetch size. For use when using large result sets. -
detachmentOptions
int detachmentOptionsOptions to be used during detachment. Spec 12.7 says that the default is DETACH_LOAD_FIELDS. -
fetchPlansByClassName
FetchPlanForClass keyed by the class name. -
maxFetchDepth
int maxFetchDepthMaximum depth to fetch from the root object. -
detachmentRootClasses
Class[] detachmentRootClassesThe classes used as the roots for detachment (DetachAllOnCommit). -
detachmentRoots
Collection<Object> detachmentRootsThe instances used as the roots for detachment (DetachAllOnCommit). -
isToCallPostLoadFetchPlanByCmd
Cache the result of FetchPlanImpl.isToCallPostLoadFetchPlan(): for a given set of loaded members of a certain class. Must be invalidated with any change of fields to load, e.g. adding a fetchgroup.
-
-
Constructor Details
-
FetchPlan
Constructor. Initially has the default fetch group.- Parameters:
ec
- execution contextclr
- ClassLoader Resolver
-
-
Method Details
-
markDirty
private void markDirty()Mark all managed fetch plans to be dirty, so the active members need to be recomputed. -
getFetchPlanForClass
Access the fetch plan for the class.- Parameters:
cmd
- metadata for the class- Returns:
- the FetchPlanForClass
-
addGroup
Method to add a group to the fetch plan.- Parameters:
grpName
- The fetch group to add- Returns:
- Updated Fetch Plan
-
removeGroup
Method to remove a group from the fetch plan.- Parameters:
grpName
- The fetch group to remove- Returns:
- Updated Fetch Plan
-
clearGroups
Method to clear the current groups and activate the DFG.- Returns:
- The FetchPlan
-
getGroups
Accessor for the static groups for this FetchPlan. Doesn't return the dynamic groups.- Returns:
- The fetch plan groups (unmodifiable)
-
setGroups
Method to set the groups of the fetch plan.- Parameters:
grpNames
- Names of the groups- Returns:
- Updated Fetch Plan
-
setGroups
Method to set the groups using an array.- Parameters:
grpNames
- Names of the groups- Returns:
- The Fetch Plan
-
setGroup
Method to set the fetch group.- Parameters:
grpName
- Name of the group- Returns:
- The Fetch Plan
-
clearDynamicGroups
private void clearDynamicGroups()Convenience method to clear all dynamic groups. -
addDynamicGroup
Convenience method to add dynamic fetch groups for the specified name.- Parameters:
grpName
- Name of group- Returns:
- Whether the groups were changed
-
notifyFetchGroupChange
Method to notify this FetchPlan that the specified FetchGroup has been updated. dynamic fetch groups extension- Parameters:
group
- The dynamic FetchGroup
-
notifyFetchGroupRemove
Method to notify this FetchPlan that the specified FetchGroup has been updated. dynamic fetch groups extension- Parameters:
group
- The dynamic FetchGroup
-
setDetachmentRoots
Set the roots for DetachAllOnCommit- Parameters:
roots
- The roots of the detachment graph.- Returns:
- The fetch plan with these roots
-
getDetachmentRoots
Accessor for the roots of the detachment graph for DetachAllOnCommit.- Returns:
- The roots of the detachment graph.
-
setDetachmentRootClasses
Set the classes used for roots of the detachment graph for DetachAllOnCommit.- Parameters:
rootClasses
- Classes to be used as roots of the detachment graph- Returns:
- The fetch plan with these roots
-
getDetachmentRootClasses
Accessor for the root classes of the detachment graph for DetachAllOnCommit.- Returns:
- The classes to be used as the root of the detachment graph.
-
resetDetachmentRoots
void resetDetachmentRoots()Method called at commit() to clear out the detachment roots. -
setMaxFetchDepth
Mutator for the maximum fetch depth where -1 implies no restriction on the fetch depth. Throws NucleusUserException when an illegal value (either 0 or ≤ -2)- Parameters:
max
- The maximum fetch depth to fetch to- Returns:
- The FetchPlan
-
getMaxFetchDepth
public int getMaxFetchDepth()Accessor for the maximum fetch depth.- Returns:
- The maximum fetch depth
-
setFetchSize
Method to set the fetch size when using large result sets.- Parameters:
fetchSize
- the size- Returns:
- Updated Fetch Plan
-
getFetchSize
public int getFetchSize()Accessor for the fetch size when using large result sets.- Returns:
- The size
-
getDetachmentOptions
public int getDetachmentOptions()Return the options to be used at detachment.- Returns:
- Detachment options
-
setDetachmentOptions
Set the options to be used at detachment.- Parameters:
options
- The options- Returns:
- The updated fetch plan.
-
getCopy
Returns a copy of this FetchPlan with all settings initialized. Used when a Query has to have its own FetchPlan, so takes a copy of that of the ExecutionContext.- Returns:
- the FetchPlan copy
-
getCachedIsToCallPostLoadFetchPlan
-
cacheIsToCallPostLoadFetchPlan
void cacheIsToCallPostLoadFetchPlan(AbstractClassMetaData cmd, BitSet loadedFields, Boolean itcplfp) -
invalidateCachedIsToCallPostLoadFetchPlan
-
toStringWithClasses
-
toString
-