javax.jdo

Interface FetchPlan

public interface FetchPlan

Fetch groups are activated using methods on this interface. An instance of this interface can be obtained from PersistenceManager.getFetchPlan(), Extent.getFetchPlan(), and Query.getFetchPlan(). When a Query or Extent is retrieved from a PersistenceManager, its FetchPlan is initialized to the same settings as that of the PersistenceManager. Subsequent modifications of the Query or Extent's FetchPlan are not reflected in the FetchPlan of the PersistenceManager.
Version:
2.0
Since:
2.0

Field Summary

static String
ALL
For use with addGroup(String), removeGroup(String), and the various setGroups calls.
static String
DEFAULT
For use with addGroup(String), removeGroup(String), and the various setGroups calls.
static int
DETACH_LOAD_FIELDS
For use with PersistenceManager.detachCopy(Object) and setDetachmentOptions(int).
static int
DETACH_UNLOAD_FIELDS
For use with PersistenceManager.detachCopy(Object) and setDetachmentOptions(int).
static int
FETCH_SIZE_GREEDY
For use with setFetchSize(int).
static int
FETCH_SIZE_OPTIMAL
For use with setFetchSize(int).

Method Summary

FetchPlan
addGroup(String fetchGroupName)
Add the fetch group to the set of active fetch groups.
FetchPlan
clearGroups()
Remove all active groups leaving no active fetch group.
int
getDetachmentOptions()
Get options used during detachment.
Class[]
getDetachmentRootClasses()
Get the root classes for DetachAllOnCommit.
Collection
getDetachmentRoots()
Get the roots for DetachAllOnCommit.
int
getFetchSize()
Return the fetch size, or FETCH_SIZE_OPTIMAL if not set, or FETCH_SIZE_GREEDY to fetch all.
Set
getGroups()
Return an immutable collection containing the names of all active fetch groups.
int
getMaxFetchDepth()
Return the maximum fetch depth used when fetching instances.
FetchPlan
removeGroup(String fetchGroupName)
Remove the fetch group from the set active fetch groups.
FetchPlan
setDetachmentOptions(int options)
Set options to be used during detachment.
FetchPlan
setDetachmentRootClasses(Class[] rootClasses)
Set the root classes for DetachAllOnCommit.
FetchPlan
setDetachmentRoots(Collection roots)
Set the roots for DetachAllOnCommit.
FetchPlan
setFetchSize(int fetchSize)
Set the fetch size for large result set support.
FetchPlan
setGroup(String fetchGroupName)
Set the active fetch groups to the single named fetch group.
FetchPlan
setGroups(Collection fetchGroupNames)
Set a collection of groups.
FetchPlan
setGroups(String[] fetchGroupNames)
Set a collection of groups.
FetchPlan
setMaxFetchDepth(int fetchDepth)
Set the maximum fetch depth when fetching.

Field Details

ALL

public static final String ALL
For use with addGroup(String), removeGroup(String), and the various setGroups calls. Value: all.
Since:
2.0

DEFAULT

public static final String DEFAULT
For use with addGroup(String), removeGroup(String), and the various setGroups calls. Value: default.
Since:
2.0

DETACH_LOAD_FIELDS

public static final int DETACH_LOAD_FIELDS
For use with PersistenceManager.detachCopy(Object) and setDetachmentOptions(int). Specifies that fields that are not loaded but are in the current fetch plan should be loaded prior to detachment.
Field Value:
1
Since:
2.0

DETACH_UNLOAD_FIELDS

public static final int DETACH_UNLOAD_FIELDS
For use with PersistenceManager.detachCopy(Object) and setDetachmentOptions(int). Specifies that fields that are loaded but not in the current fetch plan should be unloaded prior to detachment.
Field Value:
2
Since:
2.0

FETCH_SIZE_GREEDY

public static final int FETCH_SIZE_GREEDY
Field Value:
-1
Since:
2.0

FETCH_SIZE_OPTIMAL

public static final int FETCH_SIZE_OPTIMAL
Field Value:
0
Since:
2.0

Method Details

addGroup

public FetchPlan addGroup(String fetchGroupName)
Add the fetch group to the set of active fetch groups.
Returns:
the FetchPlan
Since:
2.0

clearGroups

public FetchPlan clearGroups()
Remove all active groups leaving no active fetch group.
Returns:
the FetchPlan
Since:
2.0

getDetachmentOptions

public int getDetachmentOptions()
Get options used during detachment.

getDetachmentRootClasses

public Class[] getDetachmentRootClasses()
Get the root classes for DetachAllOnCommit.
Returns:
The detachment root classes
Since:
2.0

getDetachmentRoots

public Collection getDetachmentRoots()
Get the roots for DetachAllOnCommit.
Returns:
Collection of detachment roots.
Since:
2.0

getFetchSize

public int getFetchSize()
Returns:
the fetch size
Since:
2.0

getGroups

public Set getGroups()
Return an immutable collection containing the names of all active fetch groups.
Returns:
an immutable collection containing the names of all active fetch groups
Since:
2.0

getMaxFetchDepth

public int getMaxFetchDepth()
Return the maximum fetch depth used when fetching instances.
Returns:
the maximum fetch depth
Since:
2.0

removeGroup

public FetchPlan removeGroup(String fetchGroupName)
Remove the fetch group from the set active fetch groups.
Returns:
the FetchPlan
Since:
2.0

setDetachmentOptions

public FetchPlan setDetachmentOptions(int options)
Set options to be used during detachment. Options are DETACH_LOAD_FIELDS and DETACH_UNLOAD_FIELDS.

setDetachmentRootClasses

public FetchPlan setDetachmentRootClasses(Class[] rootClasses)
Set the root classes for DetachAllOnCommit.
Parameters:
rootClasses - The root classes.
Since:
2.0

setDetachmentRoots

public FetchPlan setDetachmentRoots(Collection roots)
Set the roots for DetachAllOnCommit.
Parameters:
roots - Collection of the detachment roots.
Since:
2.0

setFetchSize

public FetchPlan setFetchSize(int fetchSize)
Set the fetch size for large result set support. Use FETCH_SIZE_OPTIMAL to unset, and FETCH_SIZE_GREEDY to force loading of everything.
Parameters:
fetchSize - the fetch size
Returns:
the FetchPlan
Since:
2.0

setGroup

public FetchPlan setGroup(String fetchGroupName)
Set the active fetch groups to the single named fetch group.
Parameters:
fetchGroupName - the single fetch group
Returns:
the FetchPlan
Since:
2.0

setGroups

public FetchPlan setGroups(Collection fetchGroupNames)
Set a collection of groups.
Parameters:
fetchGroupNames - a collection of names of fetch groups
Returns:
the FetchPlan
Since:
2.0

setGroups

public FetchPlan setGroups(String[] fetchGroupNames)
Set a collection of groups.
Parameters:
fetchGroupNames - a String array of names of fetch groups
Returns:
the FetchPlan
Since:
2.0

setMaxFetchDepth

public FetchPlan setMaxFetchDepth(int fetchDepth)
Set the maximum fetch depth when fetching. A value of 0 has no meaning and will throw a JDOUserException. A value of -1 means that no limit is placed on fetching. A positive integer will result in that number of references from the initial object to be fetched.
Parameters:
fetchDepth - the depth
Returns:
the FetchPlan
Since:
2.0