Package org.apache.openjpa.kernel
Class DelegatingFetchConfiguration
- java.lang.Object
-
- org.apache.openjpa.kernel.DelegatingFetchConfiguration
-
- All Implemented Interfaces:
Serializable,Cloneable,FetchConfiguration,LockLevels,LockScopes,QueryFlushModes
- Direct Known Subclasses:
DelegatingJDBCFetchConfiguration
public class DelegatingFetchConfiguration extends Object implements FetchConfiguration
Delegating fetch configuration that can also perform exception translation for use in facades.- Author:
- Abe White
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.apache.openjpa.kernel.FetchConfiguration
DEFAULT, FETCH_LOAD, FETCH_NONE, FETCH_REF
-
Fields inherited from interface org.apache.openjpa.kernel.LockLevels
LOCK_NONE, LOCK_READ, LOCK_WRITE
-
Fields inherited from interface org.apache.openjpa.kernel.LockScopes
LOCKSCOPE_EXTENDED, LOCKSCOPE_NORMAL
-
Fields inherited from interface org.apache.openjpa.kernel.QueryFlushModes
FLUSH_FALSE, FLUSH_TRUE, FLUSH_WITH_CONNECTION
-
-
Constructor Summary
Constructors Constructor Description DelegatingFetchConfiguration(FetchConfiguration fetch)Constructor; supply delegate.DelegatingFetchConfiguration(FetchConfiguration fetch, RuntimeExceptionTranslator trans)Constructor; supply delegate and exception translator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FetchConfigurationaddFetchGroup(String group)Addsgroupto the set of fetch group names to use when loading objects.FetchConfigurationaddFetchGroups(Collection groups)Addsgroupsto the set of fetch group names to use when loading objects.FetchConfigurationaddField(String field)Addsfieldto the set of fully-qualified field names to use when loading objects.FetchConfigurationaddFields(Collection fields)Addsfieldsto the set of fully-qualified field names to use when loading objects.FetchConfigurationclearFetchGroups()Clears the set of fetch group names to use when loading data.FetchConfigurationclearFields()Clears the set of field names to use when loading data.Objectclone()Clone this instance.voidcopy(FetchConfiguration fetch)Copy the state from the given fetch configuration to this one.booleanequals(Object other)DataCacheRetrieveModegetCacheRetrieveMode()Gets the current retrieve mode for data cache.DataCacheStoreModegetCacheStoreMode()Gets the current storage mode for data cache.StoreContextgetContext()Return the context associated with this configuration; may be null if it has not been set or this object has been serialized.FetchConfigurationgetDelegate()Return the direct delegate.booleangetExtendedPathLookup()Affirms if extended path lookup feature is active.intgetFetchBatchSize()Return the fetch batch size for large result set support.SetgetFetchGroups()Returns immutable set of names of the fetch groups that this component will use when loading objects.SetgetFields()Returns the set of fully-qualified field names that this component will use when loading objects.intgetFlushBeforeQueries()The query automatic flush configuration.ObjectgetHint(String name)Get the hint value for the specific key as originally set by the caller, or null if the hint is not specified.Map<String,Object>getHints()Get an immutable view of the currently active hints and their values.FetchConfigurationgetInnermostDelegate()Return the native delegate.intgetLockScope()The lock scope for next fetch.intgetLockTimeout()The number of milliseconds to wait for an object lock, or -1 for no limit.intgetMaxFetchDepth()Return the maximum depth of fetched instance graph.booleangetQueryCacheEnabled()Return whether or not query caching is enabled.intgetQueryTimeout()The number of milliseconds to wait for a query, or -1 for no limit.intgetReadLockLevel()The lock level to use for locking loaded objects.SetgetRootClasses()Root classes for recursive operations.SetgetRootInstances()Root instances for recursive operations.intgetWriteLockLevel()The lock level to use for locking dirtied objects.booleanhasFetchGroup(String group)Return true if the given fetch group has been added.booleanhasField(String field)Return true if the given fully-qualified field has been added.inthashCode()booleanisDefaultPUFetchGroupConfigurationOnly()Affirm if the Fetch Plan currently matches the Persistence Unit's configured default.booleanisFetchConfigurationSQLCacheAdmissible()Whether SQL generated by the FetchConfiguration's current configuration should be cached.booleanisHintSet(String key)Affirm if the given hint has been set in this receiver.voidlock()Synchronize on internal lock if multithreaded is true.ResultListnewResultList(ResultObjectProvider rop)Return a new result list for the current fetch configuration.FetchConfigurationremoveFetchGroup(String group)Remove the given fetch group.FetchConfigurationremoveFetchGroups(Collection groups)Removesgroupsfrom the set of fetch group names to use when loading objects.FetchConfigurationremoveField(String field)Remove the given fully-qualified field.FetchConfigurationremoveFields(Collection fields)Removesfieldsfrom the set of fully-qualified field names to use when loading objects.intrequiresFetch(FieldMetaData fmd)Affirms if the given field requires to be fetched in the context of current fetch operation.booleanrequiresLoad()Return 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.FetchConfigurationresetFetchGroups()Resets the set of fetch groups to the list in the global configuration.voidsetCacheRetrieveMode(DataCacheRetrieveMode mode)Sets the current retrieve mode for data cache.voidsetCacheStoreMode(DataCacheStoreMode mode)Sets 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.FetchConfigurationsetExtendedPathLookup(boolean flag)Sets extended path lookup feature.FetchConfigurationsetFetchBatchSize(int fetchBatchSize)Set the fetch batch size for large result set support.FetchConfigurationsetFlushBeforeQueries(int flush)The query automatic flush configuration.voidsetHint(String name, Object value)Sets an arbitrary query hint that may be utilized during execution.voidsetHint(String name, Object value, Object original)Sets an arbitrary query hint that may be utilized during execution.FetchConfigurationsetLockScope(int scope)The lock scope for next fetch.FetchConfigurationsetLockTimeout(int timeout)The number of milliseconds to wait for an object lock, or -1 for no limit.FetchConfigurationsetMaxFetchDepth(int depth)Set the maximum depth of the fetched instance graph.FetchConfigurationsetQueryCacheEnabled(boolean cache)Control whether or not query caching is enabled.FetchConfigurationsetQueryTimeout(int timeout)The number of milliseconds to wait for a query, or -1 for no limit.FetchConfigurationsetReadLockLevel(int level)The lock level to use for locking loaded objects.FetchConfigurationsetRootClasses(Collection roots)Root classes for recursive operations.FetchConfigurationsetRootInstances(Collection roots)Root instances for recursive operations.FetchConfigurationsetWriteLockLevel(int level)The lock level to use for locking dirtied objects.protected RuntimeExceptiontranslate(RuntimeException re)Translate the OpenJPA exception.FetchConfigurationtraverse(FieldMetaData fmd)Traverse the given field to generate (possibly) a new configuration state.voidunlock()Release internal lock if multithreaded is true.
-
-
-
Constructor Detail
-
DelegatingFetchConfiguration
public DelegatingFetchConfiguration(FetchConfiguration fetch)
Constructor; supply delegate.
-
DelegatingFetchConfiguration
public DelegatingFetchConfiguration(FetchConfiguration fetch, RuntimeExceptionTranslator trans)
Constructor; supply delegate and exception translator.
-
-
Method Detail
-
getDelegate
public FetchConfiguration getDelegate()
Return the direct delegate.
-
getInnermostDelegate
public FetchConfiguration getInnermostDelegate()
Return the native delegate.
-
translate
protected RuntimeException translate(RuntimeException re)
Translate the OpenJPA exception.
-
getContext
public StoreContext 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
public void setContext(StoreContext ctx)
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
-
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
public FetchConfiguration setFetchBatchSize(int fetchBatchSize)
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
public FetchConfiguration setMaxFetchDepth(int depth)
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.
-
getRootInstances
public Set getRootInstances()
Description copied from interface:FetchConfigurationRoot instances for recursive operations. This set is not thread safe.- Specified by:
getRootInstancesin interfaceFetchConfiguration
-
setRootInstances
public FetchConfiguration setRootInstances(Collection roots)
Description copied from interface:FetchConfigurationRoot instances for recursive operations.- Specified by:
setRootInstancesin interfaceFetchConfiguration
-
getRootClasses
public Set getRootClasses()
Description copied from interface:FetchConfigurationRoot classes for recursive operations. This set is not thread safe.- Specified by:
getRootClassesin interfaceFetchConfiguration
-
setRootClasses
public FetchConfiguration setRootClasses(Collection roots)
Description copied from interface:FetchConfigurationRoot classes for recursive operations.- Specified by:
setRootClassesin interfaceFetchConfiguration
-
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
public FetchConfiguration setQueryCacheEnabled(boolean cache)
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
-
setFlushBeforeQueries
public FetchConfiguration setFlushBeforeQueries(int flush)
Description copied from interface:FetchConfigurationThe query automatic flush configuration.- Specified by:
setFlushBeforeQueriesin interfaceFetchConfiguration
-
getExtendedPathLookup
public boolean getExtendedPathLookup()
Description copied from interface:FetchConfigurationAffirms if extended path lookup feature is active.- Specified by:
getExtendedPathLookupin interfaceFetchConfiguration
-
setExtendedPathLookup
public FetchConfiguration setExtendedPathLookup(boolean flag)
Description copied from interface:FetchConfigurationSets extended path lookup feature.- Specified by:
setExtendedPathLookupin interfaceFetchConfiguration
-
getFetchGroups
public Set 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
public boolean hasFetchGroup(String group)
Description copied from interface:FetchConfigurationReturn true if the given fetch group has been added.- Specified by:
hasFetchGroupin interfaceFetchConfiguration
-
addFetchGroup
public FetchConfiguration addFetchGroup(String group)
Description copied from interface:FetchConfigurationAddsgroupto the set of fetch group names to use when loading objects.- Specified by:
addFetchGroupin interfaceFetchConfiguration
-
addFetchGroups
public FetchConfiguration addFetchGroups(Collection groups)
Description copied from interface:FetchConfigurationAddsgroupsto the set of fetch group names to use when loading objects.- Specified by:
addFetchGroupsin interfaceFetchConfiguration
-
removeFetchGroup
public FetchConfiguration removeFetchGroup(String group)
Description copied from interface:FetchConfigurationRemove the given fetch group.- Specified by:
removeFetchGroupin interfaceFetchConfiguration
-
removeFetchGroups
public FetchConfiguration removeFetchGroups(Collection groups)
Description copied from interface:FetchConfigurationRemovesgroupsfrom the set of fetch group names to use when loading objects.- Specified by:
removeFetchGroupsin interfaceFetchConfiguration
-
clearFetchGroups
public FetchConfiguration 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
public FetchConfiguration resetFetchGroups()
Description copied from interface:FetchConfigurationResets the set of fetch groups to the list in the global configuration.- Specified by:
resetFetchGroupsin interfaceFetchConfiguration
-
getFields
public Set 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
public boolean hasField(String field)
Description copied from interface:FetchConfigurationReturn true if the given fully-qualified field has been added.- Specified by:
hasFieldin interfaceFetchConfiguration
-
addField
public FetchConfiguration addField(String field)
Description copied from interface:FetchConfigurationAddsfieldto the set of fully-qualified field names to use when loading objects.- Specified by:
addFieldin interfaceFetchConfiguration
-
addFields
public FetchConfiguration addFields(Collection fields)
Description copied from interface:FetchConfigurationAddsfieldsto the set of fully-qualified field names to use when loading objects.- Specified by:
addFieldsin interfaceFetchConfiguration
-
removeField
public FetchConfiguration removeField(String field)
Description copied from interface:FetchConfigurationRemove the given fully-qualified field.- Specified by:
removeFieldin interfaceFetchConfiguration
-
removeFields
public FetchConfiguration removeFields(Collection fields)
Description copied from interface:FetchConfigurationRemovesfieldsfrom the set of fully-qualified field names to use when loading objects.- Specified by:
removeFieldsin interfaceFetchConfiguration
-
clearFields
public FetchConfiguration 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
-
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
public FetchConfiguration setLockTimeout(int timeout)
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
public FetchConfiguration setQueryTimeout(int timeout)
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
public FetchConfiguration setLockScope(int scope)
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
public FetchConfiguration setReadLockLevel(int level)
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
public FetchConfiguration setWriteLockLevel(int level)
Description copied from interface:FetchConfigurationThe lock level to use for locking dirtied objects.- Specified by:
setWriteLockLevelin interfaceFetchConfiguration
-
newResultList
public ResultList newResultList(ResultObjectProvider rop)
Description copied from interface:FetchConfigurationReturn a new result list for the current fetch configuration.- Specified by:
newResultListin interfaceFetchConfiguration
-
copy
public void copy(FetchConfiguration fetch)
Description copied from interface:FetchConfigurationCopy the state from the given fetch configuration to this one.- Specified by:
copyin interfaceFetchConfiguration
-
clone
public Object clone()
Description copied from interface:FetchConfigurationClone this instance.- Specified by:
clonein interfaceFetchConfiguration- Overrides:
clonein classObject
-
setHint
public void setHint(String name, Object value)
Description copied from interface:FetchConfigurationSets an arbitrary query hint that may be utilized during execution. The hint may be specific to a particular database. A hint, if known to this receiver, may have a corresponding setter method, then the hint sets the value. Otherwise the hint is stored opaquely by the receiver.
This is same as calling FetchConfiguration.setHint(String, Object, Object) with the third argument being the same as the second.- 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.
-
setHint
public void setHint(String name, Object value, Object original)
Description copied from interface:FetchConfigurationSets an arbitrary query hint that may be utilized during execution. The hint may be specific to a particular database. A hint, if known to this receiver, may have a corresponding setter method, then the hint sets the value. Otherwise the hint is stored opaquely by the receiver.- Specified by:
setHintin interfaceFetchConfiguration- Parameters:
name- the name of the hintvalue- the value of the hint. If the hint has a corresponding setter, then the type of value must be same as the setter argument.original- the value of the hint as specified by the user.
-
isHintSet
public boolean isHintSet(String key)
Description copied from interface:FetchConfigurationAffirm if the given hint has been set in this receiver.- Specified by:
isHintSetin 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
-
getHint
public Object getHint(String name)
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
-
getHints
public Map<String,Object> getHints()
Description copied from interface:FetchConfigurationGet an immutable view of the currently active hints and their values. The values are as specified by the user.- Specified by:
getHintsin interfaceFetchConfiguration
-
requiresFetch
public int requiresFetch(FieldMetaData fmd)
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
public FetchConfiguration traverse(FieldMetaData fmd)
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
-
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
-
getCacheRetrieveMode
public DataCacheRetrieveMode getCacheRetrieveMode()
Description copied from interface:FetchConfigurationGets the current retrieve mode for data cache.- Specified by:
getCacheRetrieveModein interfaceFetchConfiguration
-
getCacheStoreMode
public DataCacheStoreMode getCacheStoreMode()
Description copied from interface:FetchConfigurationGets the current storage mode for data cache.- Specified by:
getCacheStoreModein interfaceFetchConfiguration
-
setCacheRetrieveMode
public void setCacheRetrieveMode(DataCacheRetrieveMode mode)
Description copied from interface:FetchConfigurationSets the current retrieve mode for data cache.- Specified by:
setCacheRetrieveModein interfaceFetchConfiguration
-
setCacheStoreMode
public void setCacheStoreMode(DataCacheStoreMode mode)
Description copied from interface:FetchConfigurationSets the current storage mode for data cache.- Specified by:
setCacheStoreModein 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
-
-