org.apache.openjpa.persistence
Class FetchPlan

java.lang.Object
  extended by org.apache.openjpa.persistence.FetchPlan

public class FetchPlan
extends java.lang.Object

The fetch plan allows you to dynamically alter eager fetching configuration and other aspects of data loading.

Since:
4.0
Author:
Abe White

Field Summary
static int DEFAULT
          Constant to revert any setting to its default value.
static int DEPTH_INFINITE
          Infinite fetch depth.
static java.lang.String GROUP_ALL
          Fetch group representing all fields.
static java.lang.String GROUP_DEFAULT
          The default fetch group.
 
Constructor Summary
FetchPlan(org.apache.openjpa.kernel.FetchConfiguration fetch)
          Constructor; supply delegate.
 
Method Summary
 FetchPlan addFetchGroup(java.lang.String group)
          Adds group to the set of fetch group to use when loading objects.
 FetchPlan addFetchGroups(java.util.Collection groups)
          Adds groups to the set of fetch group names to use when loading objects.
 FetchPlan addFetchGroups(java.lang.String... groups)
          Adds groups to the set of fetch group names to use when loading objects.
 FetchPlan addField(java.lang.Class cls, java.lang.String field)
          Adds field to the set of field names to use when loading objects.
 FetchPlan addField(java.lang.String field)
          Adds field to the set of fully-qualified field names to use when loading objects.
 FetchPlan addFields(java.lang.Class cls, java.util.Collection fields)
          Adds fields to the set of field names to use when loading objects.
 FetchPlan addFields(java.lang.Class cls, java.lang.String... fields)
          Adds fields to the set of field names to use when loading objects.
 FetchPlan addFields(java.util.Collection fields)
          Adds fields to the set of fully-qualified field names to use when loading objects.
 FetchPlan addFields(java.lang.String... fields)
          Adds fields to the set of fully-qualified field names to use when loading objects.
 FetchPlan clearFetchGroups()
          Clears the set of fetch group names to use wen loading data.
 FetchPlan clearFields()
          Clears the set of field names to use wen loading data.
 boolean equals(java.lang.Object other)
           
 org.apache.openjpa.kernel.FetchConfiguration getDelegate()
          Delegate.
 int getFetchBatchSize()
          Return the fetch batch size for large result set support.
 java.util.Collection<java.lang.String> getFetchGroups()
          Returns the names of the fetch groups that this component will use when loading objects.
 java.util.Collection<java.lang.String> getFields()
          Returns the fully qualified names of the fields that this component will use when loading objects.
 int getLockTimeout()
          The number of milliseconds to wait for an object lock, or -1 for no limit.
 int getMaxFetchDepth()
          The maximum fetch depth when loading an object.
 boolean getQueryResultCache()
          Return whether or not query caching is enabled.
 javax.persistence.LockModeType getReadLockMode()
          The lock level to use for locking loaded objects.
 javax.persistence.LockModeType getWriteLockMode()
          The lock level to use for locking dirtied objects.
 boolean hasField(java.lang.Class cls, java.lang.String field)
          Return true if the given field has been added.
 boolean hasField(java.lang.String field)
          Return true if the given field has been added.
 int hashCode()
           
protected  org.apache.openjpa.kernel.DelegatingFetchConfiguration newDelegatingFetchConfiguration(org.apache.openjpa.kernel.FetchConfiguration fetch)
          Create a new exception-translating delegating fetch configuration.
 FetchPlan removeFetchGroup(java.lang.String group)
          Remove the given fetch group.
 FetchPlan removeFetchGroups(java.util.Collection groups)
          Removes groups from the set of fetch group names to use when loading objects.
 FetchPlan removeFetchGroups(java.lang.String... groups)
          Removes groups from the set of fetch group names to use when loading objects.
 FetchPlan removeField(java.lang.Class cls, java.lang.String field)
          Remove the given field.
 FetchPlan removeField(java.lang.String field)
          Remove the given fully-qualified field.
 FetchPlan removeFields(java.lang.Class cls, java.util.Collection fields)
          Removes fields from the set of field names to use when loading objects.
 FetchPlan removeFields(java.lang.Class cls, java.lang.String... fields)
          Removes fields from the set of field names to use when loading objects.
 FetchPlan removeFields(java.util.Collection fields)
          Removes fields from the set of fully-qualified field names to use when loading objects.
 FetchPlan removeFields(java.lang.String... fields)
          Removes fields from the set of fully-qualified field names to use when loading objects.
 FetchPlan resetFetchGroups()
          Resets the set of fetch groups to the list in the global configuration.
 FetchPlan setFetchBatchSize(int fetchBatchSize)
          Set the fetch batch size for large result set support.
 FetchPlan setLockTimeout(int timeout)
          The number of milliseconds to wait for an object lock, or -1 for no limit.
 FetchPlan setMaxFetchDepth(int depth)
          The maximum fetch depth when loading an object.
 FetchPlan setQueryResultCache(boolean cache)
          Control whether or not query caching is enabled.
 FetchPlan setReadLockMode(javax.persistence.LockModeType mode)
          The lock level to use for locking loaded objects.
 FetchPlan setWriteLockMode(javax.persistence.LockModeType mode)
          The lock level to use for locking dirtied objects.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP_ALL

public static final java.lang.String GROUP_ALL
Fetch group representing all fields.

See Also:
Constant Field Values

GROUP_DEFAULT

public static final java.lang.String GROUP_DEFAULT
The default fetch group.

See Also:
Constant Field Values

DEPTH_INFINITE

public static final int DEPTH_INFINITE
Infinite fetch depth.

See Also:
Constant Field Values

DEFAULT

public static final int DEFAULT
Constant to revert any setting to its default value.

See Also:
Constant Field Values
Constructor Detail

FetchPlan

public FetchPlan(org.apache.openjpa.kernel.FetchConfiguration fetch)
Constructor; supply delegate.

Method Detail

newDelegatingFetchConfiguration

protected org.apache.openjpa.kernel.DelegatingFetchConfiguration newDelegatingFetchConfiguration(org.apache.openjpa.kernel.FetchConfiguration fetch)
Create a new exception-translating delegating fetch configuration.


getDelegate

public org.apache.openjpa.kernel.FetchConfiguration getDelegate()
Delegate.


getMaxFetchDepth

public int getMaxFetchDepth()
The maximum fetch depth when loading an object.


setMaxFetchDepth

public FetchPlan setMaxFetchDepth(int depth)
The maximum fetch depth when loading an object.


getFetchBatchSize

public int getFetchBatchSize()
Return the fetch batch size for large result set support. Defaults to the openjpa.FetchBatchSize setting. Note that this property will be ignored under some data stores.


setFetchBatchSize

public FetchPlan setFetchBatchSize(int fetchBatchSize)
Set the fetch batch size for large result set support. Defaults to the openjpa.FetchBatchSize setting. Note that this property will be ignored under some data stores.


getQueryResultCache

public boolean getQueryResultCache()
Return whether or not query caching is enabled. If this returns true but the datacache plugin is not installed, caching will not be enabled. If this returns false, query caching will not be used even if the datacache plugin is installed.


setQueryResultCache

public FetchPlan setQueryResultCache(boolean cache)
Control whether or not query caching is enabled. This has no effect if the datacache plugin is not installed, or if the query cache size is set to zero.


getFetchGroups

public java.util.Collection<java.lang.String> getFetchGroups()
Returns the names of the fetch groups that this component will use when loading objects. Defaults to the org.apache.openjpa.FetchGroups setting.


addFetchGroup

public FetchPlan addFetchGroup(java.lang.String group)
Adds group to the set of fetch group to use when loading objects.


addFetchGroups

public FetchPlan addFetchGroups(java.lang.String... groups)
Adds groups to the set of fetch group names to use when loading objects.


addFetchGroups

public FetchPlan addFetchGroups(java.util.Collection groups)
Adds groups to the set of fetch group names to use when loading objects.


removeFetchGroup

public FetchPlan removeFetchGroup(java.lang.String group)
Remove the given fetch group.


removeFetchGroups

public FetchPlan removeFetchGroups(java.lang.String... groups)
Removes groups from the set of fetch group names to use when loading objects.


removeFetchGroups

public FetchPlan removeFetchGroups(java.util.Collection groups)
Removes groups from the set of fetch group names to use when loading objects.


clearFetchGroups

public FetchPlan clearFetchGroups()
Clears the set of fetch group names to use wen loading data. After this operation is invoked, only those fields in the default fetch group (and any requested field) will be loaded when loading an object.


resetFetchGroups

public FetchPlan resetFetchGroups()
Resets the set of fetch groups to the list in the global configuration.


getFields

public java.util.Collection<java.lang.String> getFields()
Returns the fully qualified names of the fields that this component will use when loading objects. Defaults to the empty set.


hasField

public boolean hasField(java.lang.String field)
Return true if the given field has been added.


hasField

public boolean hasField(java.lang.Class cls,
                        java.lang.String field)
Return true if the given field has been added.


addField

public FetchPlan addField(java.lang.String field)
Adds field to the set of fully-qualified field names to use when loading objects.


addField

public FetchPlan addField(java.lang.Class cls,
                          java.lang.String field)
Adds field to the set of field names to use when loading objects.


addFields

public FetchPlan addFields(java.lang.String... fields)
Adds fields to the set of fully-qualified field names to use when loading objects.


addFields

public FetchPlan addFields(java.lang.Class cls,
                           java.lang.String... fields)
Adds fields to the set of field names to use when loading objects.


addFields

public FetchPlan addFields(java.util.Collection fields)
Adds fields to the set of fully-qualified field names to use when loading objects.


addFields

public FetchPlan addFields(java.lang.Class cls,
                           java.util.Collection fields)
Adds fields to the set of field names to use when loading objects.


removeField

public FetchPlan removeField(java.lang.String field)
Remove the given fully-qualified field.


removeField

public FetchPlan removeField(java.lang.Class cls,
                             java.lang.String field)
Remove the given field.


removeFields

public FetchPlan removeFields(java.lang.String... fields)
Removes fields from the set of fully-qualified field names to use when loading objects.


removeFields

public FetchPlan removeFields(java.lang.Class cls,
                              java.lang.String... fields)
Removes fields from the set of field names to use when loading objects.


removeFields

public FetchPlan removeFields(java.util.Collection fields)
Removes fields from the set of fully-qualified field names to use when loading objects.


removeFields

public FetchPlan removeFields(java.lang.Class cls,
                              java.util.Collection fields)
Removes fields from the set of field names to use when loading objects.


clearFields

public FetchPlan clearFields()
Clears the set of field names to use wen loading data. After this operation is invoked, only those fields in the configured fetch groups will be loaded when loading an object.


getLockTimeout

public int getLockTimeout()
The number of milliseconds to wait for an object lock, or -1 for no limit.


setLockTimeout

public FetchPlan setLockTimeout(int timeout)
The number of milliseconds to wait for an object lock, or -1 for no limit.


getReadLockMode

public javax.persistence.LockModeType getReadLockMode()
The lock level to use for locking loaded objects.


setReadLockMode

public FetchPlan setReadLockMode(javax.persistence.LockModeType mode)
The lock level to use for locking loaded objects.


getWriteLockMode

public javax.persistence.LockModeType getWriteLockMode()
The lock level to use for locking dirtied objects.


setWriteLockMode

public FetchPlan setWriteLockMode(javax.persistence.LockModeType mode)
The lock level to use for locking dirtied objects.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object


Copyright © 2006 Apache Software Foundation. All Rights Reserved.