Package org.apache.openjpa.kernel
Class DelegatingFetchConfiguration
- java.lang.Object
-
- org.apache.openjpa.kernel.DelegatingFetchConfiguration
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,FetchConfiguration
,LockLevels
,LockScopes
,QueryFlushModes
- Direct Known Subclasses:
DelegatingJDBCFetchConfiguration
public class DelegatingFetchConfiguration extends java.lang.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 FetchConfiguration
addFetchGroup(java.lang.String group)
Addsgroup
to the set of fetch group names to use when loading objects.FetchConfiguration
addFetchGroups(java.util.Collection groups)
Addsgroups
to the set of fetch group names to use when loading objects.FetchConfiguration
addField(java.lang.String field)
Addsfield
to the set of fully-qualified field names to use when loading objects.FetchConfiguration
addFields(java.util.Collection fields)
Addsfields
to the set of fully-qualified field names to use when loading objects.FetchConfiguration
clearFetchGroups()
Clears the set of fetch group names to use when loading data.FetchConfiguration
clearFields()
Clears the set of field names to use when loading data.java.lang.Object
clone()
Clone this instance.void
copy(FetchConfiguration fetch)
Copy the state from the given fetch configuration to this one.boolean
equals(java.lang.Object other)
DataCacheRetrieveMode
getCacheRetrieveMode()
Gets the current retrieve mode for data cache.DataCacheStoreMode
getCacheStoreMode()
Gets the current storage mode for data cache.StoreContext
getContext()
Return the context associated with this configuration; may be null if it has not been set or this object has been serialized.FetchConfiguration
getDelegate()
Return the direct delegate.boolean
getExtendedPathLookup()
Affirms if extended path lookup feature is active.int
getFetchBatchSize()
Return the fetch batch size for large result set support.java.util.Set
getFetchGroups()
Returns immutable set of names of the fetch groups that this component will use when loading objects.java.util.Set
getFields()
Returns the set of fully-qualified field names that this component will use when loading objects.int
getFlushBeforeQueries()
The query automatic flush configuration.java.lang.Object
getHint(java.lang.String name)
Get the hint value for the specific key as originally set by the caller, or null if the hint is not specified.java.util.Map<java.lang.String,java.lang.Object>
getHints()
Get an immutable view of the currently active hints and their values.FetchConfiguration
getInnermostDelegate()
Return the native delegate.int
getLockScope()
The lock scope for next fetch.int
getLockTimeout()
The number of milliseconds to wait for an object lock, or -1 for no limit.int
getMaxFetchDepth()
Return the maximum depth of fetched instance graph.boolean
getQueryCacheEnabled()
Return whether or not query caching is enabled.int
getQueryTimeout()
The number of milliseconds to wait for a query, or -1 for no limit.int
getReadLockLevel()
The lock level to use for locking loaded objects.java.util.Set
getRootClasses()
Root classes for recursive operations.java.util.Set
getRootInstances()
Root instances for recursive operations.int
getWriteLockLevel()
The lock level to use for locking dirtied objects.boolean
hasFetchGroup(java.lang.String group)
Return true if the given fetch group has been added.boolean
hasField(java.lang.String field)
Return true if the given fully-qualified field has been added.int
hashCode()
boolean
isDefaultPUFetchGroupConfigurationOnly()
Affirm if the Fetch Plan currently matches the Persistence Unit's configured default.boolean
isFetchConfigurationSQLCacheAdmissible()
Whether SQL generated by the FetchConfiguration's current configuration should be cached.boolean
isHintSet(java.lang.String key)
Affirm if the given hint has been set in this receiver.void
lock()
Synchronize on internal lock if multithreaded is true.ResultList
newResultList(ResultObjectProvider rop)
Return a new result list for the current fetch configuration.FetchConfiguration
removeFetchGroup(java.lang.String group)
Remove the given fetch group.FetchConfiguration
removeFetchGroups(java.util.Collection groups)
Removesgroups
from the set of fetch group names to use when loading objects.FetchConfiguration
removeField(java.lang.String field)
Remove the given fully-qualified field.FetchConfiguration
removeFields(java.util.Collection fields)
Removesfields
from the set of fully-qualified field names to use when loading objects.int
requiresFetch(FieldMetaData fmd)
Affirms if the given field requires to be fetched in the context of current fetch operation.boolean
requiresLoad()
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_REF
field.FetchConfiguration
resetFetchGroups()
Resets the set of fetch groups to the list in the global configuration.void
setCacheRetrieveMode(DataCacheRetrieveMode mode)
Sets the current retrieve mode for data cache.void
setCacheStoreMode(DataCacheStoreMode mode)
Sets the current storage mode for data cache.void
setContext(StoreContext ctx)
Called automatically by the system to associate the fetch configuration with a context before use.FetchConfiguration
setExtendedPathLookup(boolean flag)
Sets extended path lookup feature.FetchConfiguration
setFetchBatchSize(int fetchBatchSize)
Set the fetch batch size for large result set support.FetchConfiguration
setFlushBeforeQueries(int flush)
The query automatic flush configuration.void
setHint(java.lang.String name, java.lang.Object value)
Sets an arbitrary query hint that may be utilized during execution.void
setHint(java.lang.String name, java.lang.Object value, java.lang.Object original)
Sets an arbitrary query hint that may be utilized during execution.FetchConfiguration
setLockScope(int scope)
The lock scope for next fetch.FetchConfiguration
setLockTimeout(int timeout)
The number of milliseconds to wait for an object lock, or -1 for no limit.FetchConfiguration
setMaxFetchDepth(int depth)
Set the maximum depth of the fetched instance graph.FetchConfiguration
setQueryCacheEnabled(boolean cache)
Control whether or not query caching is enabled.FetchConfiguration
setQueryTimeout(int timeout)
The number of milliseconds to wait for a query, or -1 for no limit.FetchConfiguration
setReadLockLevel(int level)
The lock level to use for locking loaded objects.FetchConfiguration
setRootClasses(java.util.Collection roots)
Root classes for recursive operations.FetchConfiguration
setRootInstances(java.util.Collection roots)
Root instances for recursive operations.FetchConfiguration
setWriteLockLevel(int level)
The lock level to use for locking dirtied objects.protected java.lang.RuntimeException
translate(java.lang.RuntimeException re)
Translate the OpenJPA exception.FetchConfiguration
traverse(FieldMetaData fmd)
Traverse the given field to generate (possibly) a new configuration state.void
unlock()
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.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
translate
protected java.lang.RuntimeException translate(java.lang.RuntimeException re)
Translate the OpenJPA exception.
-
getContext
public StoreContext getContext()
Description copied from interface:FetchConfiguration
Return the context associated with this configuration; may be null if it has not been set or this object has been serialized.- Specified by:
getContext
in interfaceFetchConfiguration
-
setContext
public void setContext(StoreContext ctx)
Description copied from interface:FetchConfiguration
Called 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:
setContext
in interfaceFetchConfiguration
-
getFetchBatchSize
public int getFetchBatchSize()
Description copied from interface:FetchConfiguration
Return the fetch batch size for large result set support. Defaults to theopenjpa.FetchBatchSize
setting. Note that this property will be ignored under some data stores.- Specified by:
getFetchBatchSize
in interfaceFetchConfiguration
-
setFetchBatchSize
public FetchConfiguration setFetchBatchSize(int fetchBatchSize)
Description copied from interface:FetchConfiguration
Set the fetch batch size for large result set support. Defaults to theopenjpa.FetchBatchSize
setting. Note that this property will be ignored under some data stores.- Specified by:
setFetchBatchSize
in interfaceFetchConfiguration
-
getMaxFetchDepth
public int getMaxFetchDepth()
Description copied from interface:FetchConfiguration
Return the maximum depth of fetched instance graph. Defaults to1
- Specified by:
getMaxFetchDepth
in interfaceFetchConfiguration
-
setMaxFetchDepth
public FetchConfiguration setMaxFetchDepth(int depth)
Description copied from interface:FetchConfiguration
Set the maximum depth of the fetched instance graph.- Specified by:
setMaxFetchDepth
in interfaceFetchConfiguration
- Parameters:
depth
- denotes limiting length of traversal path from a root instance.-1
implies no limit.0
is not permissible.
-
getRootInstances
public java.util.Set getRootInstances()
Description copied from interface:FetchConfiguration
Root instances for recursive operations. This set is not thread safe.- Specified by:
getRootInstances
in interfaceFetchConfiguration
-
setRootInstances
public FetchConfiguration setRootInstances(java.util.Collection roots)
Description copied from interface:FetchConfiguration
Root instances for recursive operations.- Specified by:
setRootInstances
in interfaceFetchConfiguration
-
getRootClasses
public java.util.Set getRootClasses()
Description copied from interface:FetchConfiguration
Root classes for recursive operations. This set is not thread safe.- Specified by:
getRootClasses
in interfaceFetchConfiguration
-
setRootClasses
public FetchConfiguration setRootClasses(java.util.Collection roots)
Description copied from interface:FetchConfiguration
Root classes for recursive operations.- Specified by:
setRootClasses
in interfaceFetchConfiguration
-
getQueryCacheEnabled
public boolean getQueryCacheEnabled()
Description copied from interface:FetchConfiguration
Return whether or not query caching is enabled. If this returnstrue
but 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:
getQueryCacheEnabled
in interfaceFetchConfiguration
-
setQueryCacheEnabled
public FetchConfiguration setQueryCacheEnabled(boolean cache)
Description copied from interface:FetchConfiguration
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.- Specified by:
setQueryCacheEnabled
in interfaceFetchConfiguration
-
getFlushBeforeQueries
public int getFlushBeforeQueries()
Description copied from interface:FetchConfiguration
The query automatic flush configuration.- Specified by:
getFlushBeforeQueries
in interfaceFetchConfiguration
-
setFlushBeforeQueries
public FetchConfiguration setFlushBeforeQueries(int flush)
Description copied from interface:FetchConfiguration
The query automatic flush configuration.- Specified by:
setFlushBeforeQueries
in interfaceFetchConfiguration
-
getExtendedPathLookup
public boolean getExtendedPathLookup()
Description copied from interface:FetchConfiguration
Affirms if extended path lookup feature is active.- Specified by:
getExtendedPathLookup
in interfaceFetchConfiguration
-
setExtendedPathLookup
public FetchConfiguration setExtendedPathLookup(boolean flag)
Description copied from interface:FetchConfiguration
Sets extended path lookup feature.- Specified by:
setExtendedPathLookup
in interfaceFetchConfiguration
-
getFetchGroups
public java.util.Set getFetchGroups()
Description copied from interface:FetchConfiguration
Returns immutable set of names of the fetch groups that this component will use when loading objects. Defaults to theopenjpa.FetchGroups
setting. This set is not thread safe.- Specified by:
getFetchGroups
in interfaceFetchConfiguration
-
hasFetchGroup
public boolean hasFetchGroup(java.lang.String group)
Description copied from interface:FetchConfiguration
Return true if the given fetch group has been added.- Specified by:
hasFetchGroup
in interfaceFetchConfiguration
-
addFetchGroup
public FetchConfiguration addFetchGroup(java.lang.String group)
Description copied from interface:FetchConfiguration
Addsgroup
to the set of fetch group names to use when loading objects.- Specified by:
addFetchGroup
in interfaceFetchConfiguration
-
addFetchGroups
public FetchConfiguration addFetchGroups(java.util.Collection groups)
Description copied from interface:FetchConfiguration
Addsgroups
to the set of fetch group names to use when loading objects.- Specified by:
addFetchGroups
in interfaceFetchConfiguration
-
removeFetchGroup
public FetchConfiguration removeFetchGroup(java.lang.String group)
Description copied from interface:FetchConfiguration
Remove the given fetch group.- Specified by:
removeFetchGroup
in interfaceFetchConfiguration
-
removeFetchGroups
public FetchConfiguration removeFetchGroups(java.util.Collection groups)
Description copied from interface:FetchConfiguration
Removesgroups
from the set of fetch group names to use when loading objects.- Specified by:
removeFetchGroups
in interfaceFetchConfiguration
-
clearFetchGroups
public FetchConfiguration clearFetchGroups()
Description copied from interface:FetchConfiguration
Clears 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:
clearFetchGroups
in interfaceFetchConfiguration
-
resetFetchGroups
public FetchConfiguration resetFetchGroups()
Description copied from interface:FetchConfiguration
Resets the set of fetch groups to the list in the global configuration.- Specified by:
resetFetchGroups
in interfaceFetchConfiguration
-
getFields
public java.util.Set getFields()
Description copied from interface:FetchConfiguration
Returns 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:
getFields
in interfaceFetchConfiguration
-
hasField
public boolean hasField(java.lang.String field)
Description copied from interface:FetchConfiguration
Return true if the given fully-qualified field has been added.- Specified by:
hasField
in interfaceFetchConfiguration
-
addField
public FetchConfiguration addField(java.lang.String field)
Description copied from interface:FetchConfiguration
Addsfield
to the set of fully-qualified field names to use when loading objects.- Specified by:
addField
in interfaceFetchConfiguration
-
addFields
public FetchConfiguration addFields(java.util.Collection fields)
Description copied from interface:FetchConfiguration
Addsfields
to the set of fully-qualified field names to use when loading objects.- Specified by:
addFields
in interfaceFetchConfiguration
-
removeField
public FetchConfiguration removeField(java.lang.String field)
Description copied from interface:FetchConfiguration
Remove the given fully-qualified field.- Specified by:
removeField
in interfaceFetchConfiguration
-
removeFields
public FetchConfiguration removeFields(java.util.Collection fields)
Description copied from interface:FetchConfiguration
Removesfields
from the set of fully-qualified field names to use when loading objects.- Specified by:
removeFields
in interfaceFetchConfiguration
-
clearFields
public FetchConfiguration clearFields()
Description copied from interface:FetchConfiguration
Clears 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:
clearFields
in interfaceFetchConfiguration
-
getLockTimeout
public int getLockTimeout()
Description copied from interface:FetchConfiguration
The number of milliseconds to wait for an object lock, or -1 for no limit.- Specified by:
getLockTimeout
in interfaceFetchConfiguration
-
setLockTimeout
public FetchConfiguration setLockTimeout(int timeout)
Description copied from interface:FetchConfiguration
The number of milliseconds to wait for an object lock, or -1 for no limit.- Specified by:
setLockTimeout
in interfaceFetchConfiguration
-
getQueryTimeout
public int getQueryTimeout()
Description copied from interface:FetchConfiguration
The number of milliseconds to wait for a query, or -1 for no limit.- Specified by:
getQueryTimeout
in interfaceFetchConfiguration
-
setQueryTimeout
public FetchConfiguration setQueryTimeout(int timeout)
Description copied from interface:FetchConfiguration
The number of milliseconds to wait for a query, or -1 for no limit.- Specified by:
setQueryTimeout
in interfaceFetchConfiguration
-
getLockScope
public int getLockScope()
Description copied from interface:FetchConfiguration
The lock scope for next fetch.- Specified by:
getLockScope
in interfaceFetchConfiguration
-
setLockScope
public FetchConfiguration setLockScope(int scope)
Description copied from interface:FetchConfiguration
The lock scope for next fetch.- Specified by:
setLockScope
in interfaceFetchConfiguration
-
getReadLockLevel
public int getReadLockLevel()
Description copied from interface:FetchConfiguration
The lock level to use for locking loaded objects.- Specified by:
getReadLockLevel
in interfaceFetchConfiguration
-
setReadLockLevel
public FetchConfiguration setReadLockLevel(int level)
Description copied from interface:FetchConfiguration
The lock level to use for locking loaded objects.- Specified by:
setReadLockLevel
in interfaceFetchConfiguration
-
getWriteLockLevel
public int getWriteLockLevel()
Description copied from interface:FetchConfiguration
The lock level to use for locking dirtied objects.- Specified by:
getWriteLockLevel
in interfaceFetchConfiguration
-
setWriteLockLevel
public FetchConfiguration setWriteLockLevel(int level)
Description copied from interface:FetchConfiguration
The lock level to use for locking dirtied objects.- Specified by:
setWriteLockLevel
in interfaceFetchConfiguration
-
newResultList
public ResultList newResultList(ResultObjectProvider rop)
Description copied from interface:FetchConfiguration
Return a new result list for the current fetch configuration.- Specified by:
newResultList
in interfaceFetchConfiguration
-
copy
public void copy(FetchConfiguration fetch)
Description copied from interface:FetchConfiguration
Copy the state from the given fetch configuration to this one.- Specified by:
copy
in interfaceFetchConfiguration
-
clone
public java.lang.Object clone()
Description copied from interface:FetchConfiguration
Clone this instance.- Specified by:
clone
in interfaceFetchConfiguration
- Overrides:
clone
in classjava.lang.Object
-
setHint
public void setHint(java.lang.String name, java.lang.Object value)
Description copied from interface:FetchConfiguration
Sets 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:
setHint
in interfaceFetchConfiguration
value
- 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(java.lang.String name, java.lang.Object value, java.lang.Object original)
Description copied from interface:FetchConfiguration
Sets 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:
setHint
in 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(java.lang.String key)
Description copied from interface:FetchConfiguration
Affirm if the given hint has been set in this receiver.- Specified by:
isHintSet
in interfaceFetchConfiguration
-
isDefaultPUFetchGroupConfigurationOnly
public boolean isDefaultPUFetchGroupConfigurationOnly()
Description copied from interface:FetchConfiguration
Affirm if the Fetch Plan currently matches the Persistence Unit's configured default.- Specified by:
isDefaultPUFetchGroupConfigurationOnly
in interfaceFetchConfiguration
-
getHint
public java.lang.Object getHint(java.lang.String name)
Description copied from interface:FetchConfiguration
Get the hint value for the specific key as originally set by the caller, or null if the hint is not specified.- Specified by:
getHint
in interfaceFetchConfiguration
-
getHints
public java.util.Map<java.lang.String,java.lang.Object> getHints()
Description copied from interface:FetchConfiguration
Get an immutable view of the currently active hints and their values. The values are as specified by the user.- Specified by:
getHints
in interfaceFetchConfiguration
-
requiresFetch
public int requiresFetch(FieldMetaData fmd)
Description copied from interface:FetchConfiguration
Affirms 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:
requiresFetch
in interfaceFetchConfiguration
-
requiresLoad
public boolean requiresLoad()
Description copied from interface:FetchConfiguration
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_REF
field.- Specified by:
requiresLoad
in interfaceFetchConfiguration
-
traverse
public FetchConfiguration traverse(FieldMetaData fmd)
Description copied from interface:FetchConfiguration
Traverse the given field to generate (possibly) a new configuration state.- Specified by:
traverse
in interfaceFetchConfiguration
- Returns:
- a new configuration state resulting out of traversal
-
lock
public void lock()
Description copied from interface:FetchConfiguration
Synchronize on internal lock if multithreaded is true.- Specified by:
lock
in interfaceFetchConfiguration
-
unlock
public void unlock()
Description copied from interface:FetchConfiguration
Release internal lock if multithreaded is true.- Specified by:
unlock
in interfaceFetchConfiguration
-
getCacheRetrieveMode
public DataCacheRetrieveMode getCacheRetrieveMode()
Description copied from interface:FetchConfiguration
Gets the current retrieve mode for data cache.- Specified by:
getCacheRetrieveMode
in interfaceFetchConfiguration
-
getCacheStoreMode
public DataCacheStoreMode getCacheStoreMode()
Description copied from interface:FetchConfiguration
Gets the current storage mode for data cache.- Specified by:
getCacheStoreMode
in interfaceFetchConfiguration
-
setCacheRetrieveMode
public void setCacheRetrieveMode(DataCacheRetrieveMode mode)
Description copied from interface:FetchConfiguration
Sets the current retrieve mode for data cache.- Specified by:
setCacheRetrieveMode
in interfaceFetchConfiguration
-
setCacheStoreMode
public void setCacheStoreMode(DataCacheStoreMode mode)
Description copied from interface:FetchConfiguration
Sets the current storage mode for data cache.- Specified by:
setCacheStoreMode
in interfaceFetchConfiguration
-
isFetchConfigurationSQLCacheAdmissible
public boolean isFetchConfigurationSQLCacheAdmissible()
Description copied from interface:FetchConfiguration
Whether SQL generated by the FetchConfiguration's current configuration should be cached.- Specified by:
isFetchConfigurationSQLCacheAdmissible
in interfaceFetchConfiguration
-
-