Package org.apache.openjpa.kernel
Class FetchConfigurationImpl
java.lang.Object
org.apache.openjpa.kernel.FetchConfigurationImpl
- All Implemented Interfaces:
Serializable,Cloneable,FetchConfiguration,LockLevels,LockScopes,QueryFlushModes
- Direct Known Subclasses:
JDBCFetchConfigurationImpl
Allows configuration and optimization of how objects are loaded from
the data store.
- Since:
- 0.3.0
- Author:
- Abe White, Pinaki Poddar
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classConfigurable state shared throughout a traversal chain. -
Field Summary
Fields inherited from interface org.apache.openjpa.kernel.FetchConfiguration
DEFAULT, FETCH_LOAD, FETCH_NONE, FETCH_REFFields inherited from interface org.apache.openjpa.kernel.LockLevels
LOCK_NONE, LOCK_READ, LOCK_WRITEFields inherited from interface org.apache.openjpa.kernel.LockScopes
LOCKSCOPE_EXTENDED, LOCKSCOPE_NORMALFields inherited from interface org.apache.openjpa.kernel.QueryFlushModes
FLUSH_FALSE, FLUSH_TRUE, FLUSH_WITH_CONNECTION -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionaddFetchGroup(String name) Addsgroupto the set of fetch group names to use when loading objects.addFetchGroups(Collection<String> groups) Addsgroupsto the set of fetch group names to use when loading objects.Addsfieldto the set of fully-qualified field names to use when loading objects.addFields(Collection<String> fields) Addsfieldsto the set of fully-qualified field names to use when loading objects.Clears the set of fetch group names to use when loading data.Clears the set of field names to use when loading data.clone()Clone this instance.voidcopy(FetchConfiguration fetch) Copy the state from the given fetch configuration to this one.Gets the current retrieve mode for data cache.Gets the current storage mode for data cache.Return the context associated with this configuration; may be null if it has not been set or this object has been serialized.booleanAffirms if extended path lookup feature is active.intReturn the fetch batch size for large result set support.Returns immutable set of names of the fetch groups that this component will use when loading objects.Returns the set of fully-qualified field names that this component will use when loading objects.intThe query automatic flush configuration.Get the hint value for the specific key as originally set by the caller, or null if the hint is not specified.getHints()Gets the current hints set on this receiver.intThe lock scope for next fetch.intThe number of milliseconds to wait for an object lock, or -1 for no limit.intReturn the maximum depth of fetched instance graph.booleanReturn whether or not query caching is enabled.intThe number of milliseconds to wait for a query, or -1 for no limit.intThe lock level to use for locking loaded objects.Root classes for recursive operations.Root instances for recursive operations.intThe lock level to use for locking dirtied objects.booleanhasFetchGroup(String group) Return true if the given fetch group has been added.booleanbooleanbooleanReturn true if the given fully-qualified field has been added.booleanAffirm if the Fetch Plan currently matches the Persistence Unit's configured default.booleanWhether SQL generated by the FetchConfiguration's current configuration should be cached.booleanAffirms if the given key is set as a hint.voidlock()Synchronize on internal lock if multithreaded is true.protected FetchConfigurationImplReturn a new hollow instance.ResultList<?>Return a new result list for the current fetch configuration.protected static voidpopulateHintSetter(Class<?> target, String hint, Class<?> type, String... prefixes) Populate static registry of hints.protected static voidPopulate static registry of hints.removeFetchGroup(String group) Remove the given fetch group.removeFetchGroups(Collection<String> groups) Removesgroupsfrom the set of fetch group names to use when loading objects.removeField(String field) Remove the given fully-qualified field.removeFields(Collection<String> fields) Removesfieldsfrom the set of fully-qualified field names to use when loading objects.removeHint(String name) voidremoveHint(String... keys) Removes the given keys and their hint value.intAffirms if the given field requires to be fetched in the context of current fetch operation.booleanReturn false if we know that the object being fetched with this configuration does not require a load, because this configuration came from a traversal of aFetchConfiguration.FETCH_REFfield.Resets the set of fetch groups to the list in the global configuration.voidSets the current retrieve mode for data cache.voidSets the current storage mode for data cache.voidsetContext(StoreContext ctx) Called automatically by the system to associate the fetch configuration with a context before use.setExtendedPathLookup(boolean flag) Sets extended path lookup feature.setFetchBatchSize(int fetchBatchSize) Set the fetch batch size for large result set support.setFlushBeforeQueries(int flush) The query automatic flush configuration.voidSame assetHint(key, value, value).voidSets the hint to the given value.setLockScope(int scope) The lock scope for next fetch.setLockTimeout(int timeout) The number of milliseconds to wait for an object lock, or -1 for no limit.setMaxFetchDepth(int depth) Set the maximum depth of the fetched instance graph.setQueryCacheEnabled(boolean cache) Control whether or not query caching is enabled.setQueryTimeout(int timeout) The number of milliseconds to wait for a query, or -1 for no limit.setReadLockLevel(int level) The lock level to use for locking loaded objects.setRootClasses(Collection<Class<?>> classes) Root classes for recursive operations.setRootInstances(Collection<?> instances) Root instances for recursive operations.setWriteLockLevel(int level) The lock level to use for locking dirtied objects.toString()protected StringTraverse the given field to generate (possibly) a new configuration state.voidunlock()Release internal lock if multithreaded is true.
-
Constructor Details
-
FetchConfigurationImpl
public FetchConfigurationImpl() -
FetchConfigurationImpl
-
-
Method Details
-
populateHintSetter
protected static void populateHintSetter(Class<?> target, String hint, Class<?> type, String... prefixes) Populate static registry of hints.- Parameters:
target- The name of the target class that will receive this hint.hint- the simple name of the hint without a prefix.type- the value argument type of the target setter method.prefixes- the prefixes will be added to the simple hint name.
-
populateHintSetter
protected static void populateHintSetter(Class<?> target, String method, String hint, Class<?> type, String... prefixes) Populate static registry of hints.- Parameters:
target- The name of the target class that will receive this hint.method- The name of the method in the target class that will receive this hint.hint- the simple name of the hint without a prefix.type- the value argument type of the target setter method.prefixes- the prefixes will be added to the simple hint name.
-
getContext
Description copied from interface:FetchConfigurationReturn the context associated with this configuration; may be null if it has not been set or this object has been serialized.- Specified by:
getContextin interfaceFetchConfiguration
-
setContext
Description copied from interface:FetchConfigurationCalled automatically by the system to associate the fetch configuration with a context before use. The fetch configuration properties should be synchronized with the context's configuration object. Subclasses for specific back ends cannot rely on the context's configuration implementing their back end's configuration sub-interface.- Specified by:
setContextin interfaceFetchConfiguration
-
clone
Clone this instance.- Specified by:
clonein interfaceFetchConfiguration- Overrides:
clonein classObject
-
newInstance
Return a new hollow instance. -
copy
Description copied from interface:FetchConfigurationCopy the state from the given fetch configuration to this one.- Specified by:
copyin interfaceFetchConfiguration
-
getFetchBatchSize
public int getFetchBatchSize()Description copied from interface:FetchConfigurationReturn the fetch batch size for large result set support. Defaults to theopenjpa.FetchBatchSizesetting. Note that this property will be ignored under some data stores.- Specified by:
getFetchBatchSizein interfaceFetchConfiguration
-
setFetchBatchSize
Description copied from interface:FetchConfigurationSet the fetch batch size for large result set support. Defaults to theopenjpa.FetchBatchSizesetting. Note that this property will be ignored under some data stores.- Specified by:
setFetchBatchSizein interfaceFetchConfiguration
-
getMaxFetchDepth
public int getMaxFetchDepth()Description copied from interface:FetchConfigurationReturn the maximum depth of fetched instance graph. Defaults to1- Specified by:
getMaxFetchDepthin interfaceFetchConfiguration
-
setMaxFetchDepth
Description copied from interface:FetchConfigurationSet the maximum depth of the fetched instance graph.- Specified by:
setMaxFetchDepthin interfaceFetchConfiguration- Parameters:
depth- denotes limiting length of traversal path from a root instance.-1implies no limit.0is not permissible.
-
getQueryCacheEnabled
public boolean getQueryCacheEnabled()Description copied from interface:FetchConfigurationReturn whether or not query caching is enabled. If this returnstruebut the datacache plugin is not installed, caching will not be enabled. If this returnsfalse, query caching will not be used even if the datacache plugin is installed.- Specified by:
getQueryCacheEnabledin interfaceFetchConfiguration
-
setQueryCacheEnabled
Description copied from interface:FetchConfigurationControl 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.- Specified by:
setQueryCacheEnabledin interfaceFetchConfiguration
-
getFlushBeforeQueries
public int getFlushBeforeQueries()Description copied from interface:FetchConfigurationThe query automatic flush configuration.- Specified by:
getFlushBeforeQueriesin interfaceFetchConfiguration
-
getExtendedPathLookup
public boolean getExtendedPathLookup()Description copied from interface:FetchConfigurationAffirms if extended path lookup feature is active.- Specified by:
getExtendedPathLookupin interfaceFetchConfiguration
-
setExtendedPathLookup
Description copied from interface:FetchConfigurationSets extended path lookup feature.- Specified by:
setExtendedPathLookupin interfaceFetchConfiguration
-
setFlushBeforeQueries
Description copied from interface:FetchConfigurationThe query automatic flush configuration.- Specified by:
setFlushBeforeQueriesin interfaceFetchConfiguration
-
getFetchGroups
Description copied from interface:FetchConfigurationReturns immutable set of names of the fetch groups that this component will use when loading objects. Defaults to theopenjpa.FetchGroupssetting. This set is not thread safe.- Specified by:
getFetchGroupsin interfaceFetchConfiguration
-
hasFetchGroup
Description copied from interface:FetchConfigurationReturn true if the given fetch group has been added.- Specified by:
hasFetchGroupin interfaceFetchConfiguration
-
hasFetchGroupDefault
public boolean hasFetchGroupDefault() -
hasFetchGroupAll
public boolean hasFetchGroupAll() -
addFetchGroup
Description copied from interface:FetchConfigurationAddsgroupto the set of fetch group names to use when loading objects.- Specified by:
addFetchGroupin interfaceFetchConfiguration
-
addFetchGroups
Description copied from interface:FetchConfigurationAddsgroupsto the set of fetch group names to use when loading objects.- Specified by:
addFetchGroupsin interfaceFetchConfiguration
-
removeFetchGroup
Description copied from interface:FetchConfigurationRemove the given fetch group.- Specified by:
removeFetchGroupin interfaceFetchConfiguration
-
removeFetchGroups
Description copied from interface:FetchConfigurationRemovesgroupsfrom the set of fetch group names to use when loading objects.- Specified by:
removeFetchGroupsin interfaceFetchConfiguration
-
clearFetchGroups
Description copied from interface:FetchConfigurationClears the set of fetch group names to use when 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.- Specified by:
clearFetchGroupsin interfaceFetchConfiguration
-
resetFetchGroups
Description copied from interface:FetchConfigurationResets the set of fetch groups to the list in the global configuration.- Specified by:
resetFetchGroupsin interfaceFetchConfiguration
-
isDefaultPUFetchGroupConfigurationOnly
public boolean isDefaultPUFetchGroupConfigurationOnly()Description copied from interface:FetchConfigurationAffirm if the Fetch Plan currently matches the Persistence Unit's configured default.- Specified by:
isDefaultPUFetchGroupConfigurationOnlyin interfaceFetchConfiguration
-
isFetchConfigurationSQLCacheAdmissible
public boolean isFetchConfigurationSQLCacheAdmissible()Description copied from interface:FetchConfigurationWhether SQL generated by the FetchConfiguration's current configuration should be cached.- Specified by:
isFetchConfigurationSQLCacheAdmissiblein interfaceFetchConfiguration
-
getFields
Description copied from interface:FetchConfigurationReturns the set of fully-qualified field names that this component will use when loading objects. Defaults to the empty set. This set is not thread safe.- Specified by:
getFieldsin interfaceFetchConfiguration
-
hasField
Description copied from interface:FetchConfigurationReturn true if the given fully-qualified field has been added.- Specified by:
hasFieldin interfaceFetchConfiguration
-
addField
Description copied from interface:FetchConfigurationAddsfieldto the set of fully-qualified field names to use when loading objects.- Specified by:
addFieldin interfaceFetchConfiguration
-
addFields
Description copied from interface:FetchConfigurationAddsfieldsto the set of fully-qualified field names to use when loading objects.- Specified by:
addFieldsin interfaceFetchConfiguration
-
removeField
Description copied from interface:FetchConfigurationRemove the given fully-qualified field.- Specified by:
removeFieldin interfaceFetchConfiguration
-
removeFields
Description copied from interface:FetchConfigurationRemovesfieldsfrom the set of fully-qualified field names to use when loading objects.- Specified by:
removeFieldsin interfaceFetchConfiguration
-
clearFields
Description copied from interface:FetchConfigurationClears the set of field names to use when loading data. After this operation is invoked, only those fields in the configured fetch groups will be loaded when loading an object.- Specified by:
clearFieldsin interfaceFetchConfiguration
-
getCacheRetrieveMode
Description copied from interface:FetchConfigurationGets the current retrieve mode for data cache.- Specified by:
getCacheRetrieveModein interfaceFetchConfiguration
-
getCacheStoreMode
Description copied from interface:FetchConfigurationGets the current storage mode for data cache.- Specified by:
getCacheStoreModein interfaceFetchConfiguration
-
setCacheRetrieveMode
Description copied from interface:FetchConfigurationSets the current retrieve mode for data cache.- Specified by:
setCacheRetrieveModein interfaceFetchConfiguration
-
setCacheStoreMode
Description copied from interface:FetchConfigurationSets the current storage mode for data cache.- Specified by:
setCacheStoreModein interfaceFetchConfiguration
-
getLockTimeout
public int getLockTimeout()Description copied from interface:FetchConfigurationThe number of milliseconds to wait for an object lock, or -1 for no limit.- Specified by:
getLockTimeoutin interfaceFetchConfiguration
-
setLockTimeout
Description copied from interface:FetchConfigurationThe number of milliseconds to wait for an object lock, or -1 for no limit.- Specified by:
setLockTimeoutin interfaceFetchConfiguration
-
getQueryTimeout
public int getQueryTimeout()Description copied from interface:FetchConfigurationThe number of milliseconds to wait for a query, or -1 for no limit.- Specified by:
getQueryTimeoutin interfaceFetchConfiguration
-
setQueryTimeout
Description copied from interface:FetchConfigurationThe number of milliseconds to wait for a query, or -1 for no limit.- Specified by:
setQueryTimeoutin interfaceFetchConfiguration
-
getLockScope
public int getLockScope()Description copied from interface:FetchConfigurationThe lock scope for next fetch.- Specified by:
getLockScopein interfaceFetchConfiguration
-
setLockScope
Description copied from interface:FetchConfigurationThe lock scope for next fetch.- Specified by:
setLockScopein interfaceFetchConfiguration
-
getReadLockLevel
public int getReadLockLevel()Description copied from interface:FetchConfigurationThe lock level to use for locking loaded objects.- Specified by:
getReadLockLevelin interfaceFetchConfiguration
-
setReadLockLevel
Description copied from interface:FetchConfigurationThe lock level to use for locking loaded objects.- Specified by:
setReadLockLevelin interfaceFetchConfiguration
-
getWriteLockLevel
public int getWriteLockLevel()Description copied from interface:FetchConfigurationThe lock level to use for locking dirtied objects.- Specified by:
getWriteLockLevelin interfaceFetchConfiguration
-
setWriteLockLevel
Description copied from interface:FetchConfigurationThe lock level to use for locking dirtied objects.- Specified by:
setWriteLockLevelin interfaceFetchConfiguration
-
newResultList
Description copied from interface:FetchConfigurationReturn a new result list for the current fetch configuration.- Specified by:
newResultListin interfaceFetchConfiguration
-
getHints
Gets the current hints set on this receiver. The values designate the actual value specified by the caller and not the values that may have been actually set on the state variables of this receiver.- Specified by:
getHintsin interfaceFetchConfiguration
-
isHintSet
Affirms if the given key is set as a hint.- Specified by:
isHintSetin interfaceFetchConfiguration
-
removeHint
Removes the given keys and their hint value. -
getSupportedHints
-
setHint
Same assetHint(key, value, value).- Specified by:
setHintin interfaceFetchConfigurationvalue- the value of the hint. If the hint has a corresponding setter, then the type of value must be same as the setter argument.- See Also:
-
setHint
Sets the hint to the given value. If the key corresponds to a known key, then that value is set via the setter method. Otherwise it is put into opaque hints map.
In either case, the original value is put in the hints map. So essential difference between setting a value directly by a setter and via a hint is the memory of this original value.
The other important difference is setting lock levels. Setting of lock level via setter method needs active transaction. But setting via hint does not.- Specified by:
setHintin interfaceFetchConfiguration- Parameters:
key- a hint key. If it is one of the statically registered hint key then the setter is called.value- to be set. The given value type must match the argument type of the setter, if one exists.original- value as specified by the caller. This value is put in the hints map.- Throws:
IllegalArgumentException- if the given value is not acceptable by the setter method, if one exists corresponds the given hint key.
-
getHint
Description copied from interface:FetchConfigurationGet the hint value for the specific key as originally set by the caller, or null if the hint is not specified.- Specified by:
getHintin interfaceFetchConfiguration
-
removeHint
-
getRootClasses
Description copied from interface:FetchConfigurationRoot classes for recursive operations. This set is not thread safe.- Specified by:
getRootClassesin interfaceFetchConfiguration
-
setRootClasses
Description copied from interface:FetchConfigurationRoot classes for recursive operations.- Specified by:
setRootClassesin interfaceFetchConfiguration
-
getRootInstances
Description copied from interface:FetchConfigurationRoot instances for recursive operations. This set is not thread safe.- Specified by:
getRootInstancesin interfaceFetchConfiguration
-
setRootInstances
Description copied from interface:FetchConfigurationRoot instances for recursive operations.- Specified by:
setRootInstancesin interfaceFetchConfiguration
-
lock
public void lock()Description copied from interface:FetchConfigurationSynchronize on internal lock if multithreaded is true.- Specified by:
lockin interfaceFetchConfiguration
-
unlock
public void unlock()Description copied from interface:FetchConfigurationRelease internal lock if multithreaded is true.- Specified by:
unlockin interfaceFetchConfiguration
-
requiresFetch
Description copied from interface:FetchConfigurationAffirms if the given field requires to be fetched in the context of current fetch operation. Returns one ofFetchConfiguration.FETCH_NONE,FetchConfiguration.FETCH_LOAD,FetchConfiguration.FETCH_REF.- Specified by:
requiresFetchin interfaceFetchConfiguration
-
requiresLoad
public boolean requiresLoad()Description copied from interface:FetchConfigurationReturn false if we know that the object being fetched with this configuration does not require a load, because this configuration came from a traversal of aFetchConfiguration.FETCH_REFfield.- Specified by:
requiresLoadin interfaceFetchConfiguration
-
traverse
Description copied from interface:FetchConfigurationTraverse the given field to generate (possibly) a new configuration state.- Specified by:
traversein interfaceFetchConfiguration- Returns:
- a new configuration state resulting out of traversal
-
toString
-
toString
-