public interface StoreContext
Modifier and Type | Field and Description |
---|---|
static BitSet |
EXCLUDE_ALL
Marker bitset to indicate that all field loads should be excluded in
the
find methods of this interface. |
static int |
OID_ALLOW_NEW |
static int |
OID_COPY |
static int |
OID_NODELETED |
static int |
OID_NOVALIDATE |
Modifier and Type | Method and Description |
---|---|
void |
beginStore()
Begin a data store transaction.
|
OpenJPAStateManager |
embed(Object obj,
Object id,
OpenJPAStateManager owner,
ValueMetaData ownerMeta)
Make the given instance embedded.
|
Iterator<Object> |
extentIterator(Class<?> cls,
boolean subs,
FetchConfiguration fetch,
boolean ignoreChanges)
Return an iterator over all instances of the given type.
|
Object |
find(Object oid,
boolean validate,
FindCallbacks call)
Find the persistence object with the given oid.
|
Object |
find(Object oid,
FetchConfiguration fetch,
BitSet exclude,
Object edata,
int flags)
Return the object with the given oid.
|
Object[] |
findAll(Collection<Object> oids,
boolean validate,
FindCallbacks call)
Return the objects with the given oids.
|
Object[] |
findAll(Collection<Object> oids,
FetchConfiguration fetch,
BitSet exclude,
Object edata,
int flags)
Return the objects with the given oids.
|
Object |
findCached(Object oid,
FindCallbacks call)
Return the instance for the given oid/object , or null if not
found in the L1 cache.
|
boolean |
getAllowReferenceToSiblingContext()
Affirms if this context will allow its managed instances to refer instances
that are managed by other contexts.
|
Broker |
getBroker()
Return the broker for this context, if possible.
|
ClassLoader |
getClassLoader()
Return the current thread's class loader at the time this context
was obtained.
|
OpenJPAConfiguration |
getConfiguration()
Return the configuration associated with this context.
|
Object |
getConnection()
Return the connection in use by the context, or a new connection if none.
|
Object |
getConnectionFactory()
Return the 'JTA' ConnectionFactory, looking it up from JNDI if needed.
|
Object |
getConnectionFactory2()
Return the 'NonJTA' ConnectionFactory, looking it up from JNDI if needed.
|
String |
getConnectionFactory2Name()
Return the 'NonJTA' ConnectionFactoryName.
|
String |
getConnectionFactoryName()
Return the 'JTA' connectionFactoryName
|
String |
getConnectionPassword()
Return the connection password.
|
String |
getConnectionUserName()
Return the connection user name.
|
Collection<Class<?>> |
getDeletedTypes()
Return the set of classes that have been deleted in the current
transaction.
|
int |
getDetachState()
Detach mode constant to determine which fields are part of the
detached graph.
|
Collection<Object> |
getDirtyObjects()
Return a list of current dirty instances.
|
FetchConfiguration |
getFetchConfiguration()
Return the (mutable) fetch configuration for loading objects from this
context.
|
int |
getLockLevel(Object obj)
Return the lock level of the specified object.
|
LockManager |
getLockManager()
Return the lock manager in use.
|
Collection<Object> |
getManagedObjects()
Return a list of all managed instances.
|
Object |
getObjectId(Object obj)
Return the oid of the given instance.
|
Class<?> |
getObjectIdType(Class<?> cls)
Return the application or datastore identity class the given persistent
class uses for object ids.
|
boolean |
getOrderDirtyObjects()
Whether to maintain the order in which objects are dirtied for
getDirtyObjects() . |
Collection<Object> |
getPendingTransactionalObjects()
Return a list of instances which will become transactional upon
the next transaction.
|
Collection<Class<?>> |
getPersistedTypes()
Return the set of classes that have been made persistent in the current
transaction.
|
boolean |
getPopulateDataCache()
Whether objects accessed during this transaction will be added to the
store cache.
|
boolean |
getPostLoadOnMerge()
Force sending a @PostLoad lifecycle event while merging.
|
OpenJPAStateManager |
getStateManager(Object obj)
Return the state manager for the given instance.
|
DelegatingStoreManager |
getStoreManager()
Return the store manager in use.
|
Collection<Object> |
getTransactionalObjects()
Return a list of current transaction instances.
|
Collection<Class<?>> |
getUpdatedTypes()
Return the set of classes for objects that have been modified
in the current transaction.
|
Object |
getVersion(Object obj)
Returns the current version indicator for
o . |
boolean |
hasConnection()
Whether the broker has a dedicated connection based on the configured
connection retain mode and transaction status.
|
boolean |
isActive()
Whether a logical transaction is active.
|
boolean |
isCached(List<Object> oid)
Indicate whether the oid can be found in the StoreContext's L1 cache or in the StoreManager cache.
|
boolean |
isDeleted(Object obj)
Return whether the given object is deleted.
|
boolean |
isDirty(Object obj)
Return whether the given object is dirty.
|
boolean |
isManaged()
Whether this context is using managed transactions.
|
boolean |
isNew(Object obj)
Return whether the given object is a newly-created instance registered
with
broker . |
boolean |
isPersistent(Object obj)
Return whether the given object is persistent.
|
boolean |
isStoreActive()
Whether a data store transaction is active.
|
boolean |
isTrackChangesByType()
Whether memory usage is reduced during this transaction at the expense
of tracking changes at the type level instead of the instance level,
resulting in more aggressive cache invalidation.
|
boolean |
isTransactional(Object obj)
Return whether the given object is transactional.
|
void |
lock()
Synchronizes on an internal lock if the
Multithreaded flag is set to true. |
Object |
newObjectId(Class<?> cls,
Object val)
Create a new object id instance from the given value.
|
void |
nontransactional(Object pc,
OpCallbacks call)
Make the given object non-transactional.
|
void |
nontransactionalAll(Collection<Object> objs,
OpCallbacks call)
Make the given objects nontransactional.
|
void |
popFetchConfiguration()
Pops the fetch configuration from the top of the stack, making the
next one down the active one.
|
FetchConfiguration |
pushFetchConfiguration()
Pushes a new fetch configuration that inherits from the current
fetch configuration onto a stack, and makes the new configuration
the active one.
|
FetchConfiguration |
pushFetchConfiguration(FetchConfiguration fc)
Pushes the fetch configuration argument onto a stack, and makes the new configuration
the active one.
|
void |
retrieve(Object pc,
boolean fgOnly,
OpCallbacks call)
Immediately load the given object's persistent fields.
|
void |
retrieveAll(Collection<Object> objs,
boolean fgOnly,
OpCallbacks call)
Retrieve the given objects' persistent state.
|
void |
setAllowReferenceToSiblingContext(boolean flag)
Affirms if this context will allow its managed instances to refer instances
that are managed by other contexts.
|
void |
setConnectionFactory2Name(String connectionFactory2Name)
Set the 'NonJTA' ConnectionFactoryName.
|
void |
setConnectionFactoryName(String connectionFactoryName)
Set the 'JTA' ConnectionFactoryName.
|
void |
setDetachState(int mode)
Detach mode constant to determine which fields are part of the
detached graph.
|
void |
setOrderDirtyObjects(boolean order)
Whether to maintain the order in which objects are dirtied for
getDirtyObjects() . |
void |
setPopulateDataCache(boolean cache)
Whether to populate the store cache with objects used by this
transaction.
|
void |
setPostLoadOnMerge(boolean allow)
Set to
true if the merge operation should trigger
a @PostLoad lifecycle event. |
void |
setTrackChangesByType(boolean largeTransaction)
If a large number of objects will be created, modified, or deleted
during this transaction setting this option to true will reduce memory
usage if you perform periodic flushes by tracking changes at the type
level instead of the instance level, resulting in more aggressive cache
invalidation.
|
void |
transactional(Object pc,
boolean updateVersion,
OpCallbacks call)
Make the given object transactional.
|
void |
transactionalAll(Collection<Object> objs,
boolean updateVersion,
OpCallbacks call)
Make the given objects transactional.
|
void |
unlock()
Releases the internal lock.
|
static final BitSet EXCLUDE_ALL
find
methods of this interface.static final int OID_NOVALIDATE
static final int OID_NODELETED
static final int OID_COPY
static final int OID_ALLOW_NEW
Broker getBroker()
OpenJPAConfiguration getConfiguration()
FetchConfiguration getFetchConfiguration()
FetchConfiguration pushFetchConfiguration()
FetchConfiguration pushFetchConfiguration(FetchConfiguration fc)
void popFetchConfiguration()
UserException
- if the fetch configuration stack is emptyClassLoader getClassLoader()
LockManager getLockManager()
DelegatingStoreManager getStoreManager()
DelegatingStoreManager.getInnermostDelegate()
.String getConnectionUserName()
String getConnectionPassword()
Object findCached(Object oid, FindCallbacks call)
oid
- the object's idObject find(Object oid, boolean validate, FindCallbacks call)
validate
is true, the broker will check the store
for the object, and return null if it does not exist. If
validate
is false, this method never returns null. The
broker will either return its cached instance, attempt to create a
hollow instance, or throw an ObjectNotFoundException
if
unable to return a hollow instance.validate
- if true, validate that the instance exists in the
store and load fetch group fields, otherwise return
any cached or hollow instanceObject[] findAll(Collection<Object> oids, boolean validate, FindCallbacks call)
oids
- the oids of the objects to returnfind(Object,boolean,FindCallbacks)
Object find(Object oid, FetchConfiguration fetch, BitSet exclude, Object edata, int flags)
exclude
mask. By default this method does not find new
unflushed instances, validates, and does not throw an exception
if a cached instance has been deleted concurrently. These options
are controllable through the given OID_XXX
flags.Object[] findAll(Collection<Object> oids, FetchConfiguration fetch, BitSet exclude, Object edata, int flags)
Iterator<Object> extentIterator(Class<?> cls, boolean subs, FetchConfiguration fetch, boolean ignoreChanges)
ImplHelper.close(java.lang.Object)
when no longer needed. This method delegates to
StoreManager.executeExtent(org.apache.openjpa.meta.ClassMetaData, boolean, org.apache.openjpa.kernel.FetchConfiguration)
.void retrieve(Object pc, boolean fgOnly, OpCallbacks call)
fgOnly
- indicator as to whether to retrieve only fields
in the current fetch groups, or all fieldsretrieve(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)
void retrieveAll(Collection<Object> objs, boolean fgOnly, OpCallbacks call)
fgOnly
- indicator as to whether to retrieve only fieldsretrieve(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)
OpenJPAStateManager embed(Object obj, Object id, OpenJPAStateManager owner, ValueMetaData ownerMeta)
obj
- the instance to embed; may be null to create a new instanceid
- the id to give the embedded state manager; may be
null for defaultowner
- the owning state managerownerMeta
- the value in which the object is embeddedClass<?> getObjectIdType(Class<?> cls)
Object newObjectId(Class<?> cls, Object val)
cls
- the persistent class that uses this identity valueval
- an object id instance, stringified object id, or primary
key valueCollection<Class<?>> getPersistedTypes()
Collection<Class<?>> getDeletedTypes()
Collection<Class<?>> getUpdatedTypes()
Collection<Object> getManagedObjects()
Collection<Object> getTransactionalObjects()
Collection<Object> getPendingTransactionalObjects()
Collection<Object> getDirtyObjects()
boolean getOrderDirtyObjects()
getDirtyObjects()
. Default is the store manager's decision.void setOrderDirtyObjects(boolean order)
getDirtyObjects()
. Default is the store manager's decision.OpenJPAStateManager getStateManager(Object obj)
obj
is not
a managed type or is managed by another context, throw an exception.int getLockLevel(Object obj)
boolean isDirty(Object obj)
boolean isTransactional(Object obj)
void transactional(Object pc, boolean updateVersion, OpCallbacks call)
pc
- instance to make transactionalupdateVersion
- if true, the instance's version will be
incremented at the next flushvoid transactionalAll(Collection<Object> objs, boolean updateVersion, OpCallbacks call)
objs
- instances to make transactionalupdateVersion
- if true, the instance's version will be
incremented at the next flushvoid nontransactional(Object pc, OpCallbacks call)
void nontransactionalAll(Collection<Object> objs, OpCallbacks call)
boolean isPersistent(Object obj)
boolean isNew(Object obj)
broker
.boolean isDeleted(Object obj)
int getDetachState()
DetachState.DETACH_LOADED
.void setDetachState(int mode)
DetachState.DETACH_LOADED
.boolean getPopulateDataCache()
void setPopulateDataCache(boolean cache)
boolean isTrackChangesByType()
void setTrackChangesByType(boolean largeTransaction)
RemoteCommitEvent
s. Defaults to false.boolean isManaged()
boolean isActive()
boolean isStoreActive()
void beginStore()
boolean hasConnection()
Object getConnection()
void lock()
Multithreaded
flag is set to true. Make sure to call
unlock()
in a finally clause of the same method.void unlock()
String getConnectionFactoryName()
void setConnectionFactoryName(String connectionFactoryName)
String getConnectionFactory2Name()
void setConnectionFactory2Name(String connectionFactory2Name)
Object getConnectionFactory()
Object getConnectionFactory2()
boolean isCached(List<Object> oid)
oid
- List of ObjectIds for PersistenceCapables which may be found in memory.void setAllowReferenceToSiblingContext(boolean flag)
boolean getAllowReferenceToSiblingContext()
void setPostLoadOnMerge(boolean allow)
true
if the merge operation should trigger
a @PostLoad lifecycle event.allow
- PostLoad lifecycle events to be triggered on a merge operationboolean getPostLoadOnMerge()
false
by defaultCopyright © 2006–2017 Apache Software Foundation. All rights reserved.