Package org.apache.openjpa.kernel
Class BrokerImpl
- java.lang.Object
-
- org.apache.openjpa.kernel.BrokerImpl
-
- All Implemented Interfaces:
jakarta.transaction.Synchronization
,java.io.Serializable
,java.lang.Cloneable
,CallbackModes
,AutoClear
,AutoDetach
,Broker
,ConnectionRetainModes
,DetachState
,FindCallbacks
,LockLevels
,RestoreState
,StoreContext
,Closeable
- Direct Known Subclasses:
FinalizingBrokerImpl
public class BrokerImpl extends java.lang.Object implements Broker, FindCallbacks, java.lang.Cloneable, java.io.Serializable
ConcreteBroker
. The broker handles object-level behavior, but leaves all interaction with the data store to aStoreManager
that must be supplied at initialization.- Author:
- Abe White
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BrokerImpl.StateManagerId
Unique id for state managers of new datastore instances without assigned object ids.
-
Field Summary
Fields Modifier and Type Field Description protected static int
FLUSH_COMMIT
Flush in preparation of commit.protected static int
FLUSH_INC
Incremental flush.protected static int
FLUSH_LOGICAL
Run persistence-by-reachability and other flush-time operations without accessing the database.protected static int
FLUSH_ROLLBACK
Flush to check consistency of cache, then immediately rollback changes.-
Fields inherited from interface org.apache.openjpa.kernel.AutoClear
CLEAR_ALL, CLEAR_DATASTORE
-
Fields inherited from interface org.apache.openjpa.kernel.AutoDetach
DETACH_CLOSE, DETACH_COMMIT, DETACH_NONE, DETACH_NONTXREAD, DETACH_ROLLBACK, names, values
-
Fields inherited from interface org.apache.openjpa.event.CallbackModes
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACK
-
Fields inherited from interface org.apache.openjpa.kernel.ConnectionRetainModes
CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANS
-
Fields inherited from interface org.apache.openjpa.kernel.DetachState
DETACH_ALL, DETACH_FETCH_GROUPS, DETACH_FGS, DETACH_LOADED
-
Fields inherited from interface org.apache.openjpa.kernel.LockLevels
LOCK_NONE, LOCK_READ, LOCK_WRITE
-
Fields inherited from interface org.apache.openjpa.kernel.RestoreState
RESTORE_ALL, RESTORE_IMMUTABLE, RESTORE_NONE
-
Fields inherited from interface org.apache.openjpa.kernel.StoreContext
EXCLUDE_ALL, OID_ALLOW_NEW, OID_COPY, OID_NODELETED, OID_NOVALIDATE
-
-
Constructor Summary
Constructors Constructor Description BrokerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLifecycleListener(java.lang.Object listener, java.lang.Class[] classes)
Register a listener for lifecycle-related events on the specified classes.void
addTransactionListener(java.lang.Object tl)
Register a listener for transaction-related events.void
afterCompletion(int status)
void
assertActiveTransaction()
Throw an exception if there is no active transaction.void
assertNontransactionalRead()
Throw an exception if there is no transaction active and nontransactional reading is not enabled.void
assertOpen()
Throw an exception if the context is closed.protected PersistenceCapable
assertPersistenceCapable(java.lang.Object obj)
Return the given instance as aPersistenceCapable
.void
assertWriteOperation()
Throw an exception if a write operation is not permitted (there is no active transaction and nontransactional writing is not enabled).protected void
assignObjectId(java.lang.Object cache, java.lang.Object id, StateManagerImpl sm)
Assign the object id to the cache.java.lang.Object
attach(java.lang.Object obj, boolean copyNew, OpCallbacks call)
Import the specified detached object into the broker.java.lang.Object[]
attachAll(java.util.Collection objs, boolean copyNew, OpCallbacks call)
Import the specified objects into the broker.void
beforeCompletion()
void
begin()
Begin a transaction.boolean
beginOperation(boolean syncTrans)
Begin a logical operation.void
beginStore()
Begin a data store transaction.boolean
cancelAll()
Cancel all pending data store statements.protected void
checkForDuplicateId(java.lang.Object id, java.lang.Object obj, ClassMetaData meta)
This method makes sure we don't already have the instance cachedprotected void
clearStatusFlag(int flag)
Clears the given flag from the status.java.lang.Object
clone()
void
close()
Close the broker.void
commit()
Commit the current transaction.void
commitAndResume()
Issue a commit and then start a new transaction.void
delete(java.lang.Object obj, OpCallbacks call)
Delete the given object.void
deleteAll(java.util.Collection objs, OpCallbacks call)
Delete the given objects.java.lang.Object
detach(java.lang.Object obj, OpCallbacks call)
Detach the specified object from the broker.java.lang.Object[]
detachAll(java.util.Collection objs, OpCallbacks call)
Detach the specified objects from the broker.void
detachAll(OpCallbacks call)
Detach all objects in place.void
detachAll(OpCallbacks call, boolean flush)
Detach all objects in place, with the option of performing a flush before doing the detachment.void
dirtyType(java.lang.Class cls)
Mark the given class as dirty within the current transaction.OpenJPAStateManager
embed(java.lang.Object obj, java.lang.Object id, OpenJPAStateManager owner, ValueMetaData ownerMeta)
Make the given instance embedded.boolean
endOperation()
Mark the operation over.protected void
endTransaction(int status)
End the current transaction, making appropriate state transitions.void
evict(java.lang.Object obj, OpCallbacks call)
Evict the given object.void
evictAll(java.util.Collection objs, OpCallbacks call)
Evict the given objects.void
evictAll(Extent extent, OpCallbacks call)
Evict all persistent-clean and persistent-nontransactional instances in the givenExtent
.void
evictAll(OpCallbacks call)
Evict all clean objects.java.util.Iterator
extentIterator(java.lang.Class type, boolean subclasses, FetchConfiguration fetch, boolean ignoreChanges)
Return an iterator over all instances of the given type.java.lang.Object
find(java.lang.Object oid, boolean validate, FindCallbacks call)
Find the persistence object with the given oid.java.lang.Object
find(java.lang.Object oid, FetchConfiguration fetch, java.util.BitSet exclude, java.lang.Object edata, int flags)
Return the object with the given oid.protected java.lang.Object
find(java.lang.Object oid, FetchConfiguration fetch, java.util.BitSet exclude, java.lang.Object edata, int flags, FindCallbacks call)
Internal finder.java.lang.Object[]
findAll(java.util.Collection oids, boolean validate, FindCallbacks call)
Return the objects with the given oids.java.lang.Object[]
findAll(java.util.Collection oids, FetchConfiguration fetch, java.util.BitSet exclude, java.lang.Object edata, int flags)
Return the objects with the given oids.protected java.lang.Object[]
findAll(java.util.Collection oids, FetchConfiguration fetch, java.util.BitSet exclude, java.lang.Object edata, int flags, FindCallbacks call)
Internal finder.java.lang.Object
findCached(java.lang.Object oid, FindCallbacks call)
Return the instance for the given oid/object , or null if not found in the L1 cache.void
flush()
Flush all transactional instances to the data store.protected void
flush(int reason)
Flush the transactional state to the data store.protected void
free()
Free the resources used by this persistence manager.boolean
getAllowReferenceToSiblingContext()
Affirms if this context will allow its managed instances to refer instances that are managed by other contexts.int
getAutoClear()
Whether objects clear when entering transactions.int
getAutoDetach()
Bit flags marked inAutoDetach
which indicate when persistent managed objects should be automatically detached in-place.Broker
getBroker()
Return the broker for this context, if possible.BrokerFactory
getBrokerFactory()
Return the factory that produced this broker.boolean
getCacheFinderQuery()
boolean
getCachePreparedQuery()
Affirms if this receiver is caching prepared queries.java.lang.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.java.lang.Object
getConnection()
Return the connection in use by the context, or a new connection if none.java.lang.Object
getConnectionFactory()
Return the 'JTA' ConnectionFactory, looking it up from JNDI if needed.java.lang.Object
getConnectionFactory2()
Return the 'NonJTA' ConnectionFactory, looking it up from JNDI if needed.java.lang.String
getConnectionFactory2Name()
Return the 'NonJTA' ConnectionFactoryName.java.lang.String
getConnectionFactoryName()
Return the 'JTA' connectionFactoryNamejava.lang.String
getConnectionPassword()
Return the connection password.int
getConnectionRetainMode()
Return the connection retain mode for this broker.java.lang.String
getConnectionUserName()
Return the connection user name.java.util.Collection
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.java.util.Collection
getDirtyObjects()
Return a list of current dirty instances.protected java.util.Collection
getDirtyStates()
Return a copy of all dirty state managers.boolean
getEvictFromDataCache()
Whether to also evict an object from the store cache when it is evicted through this broker.FetchConfiguration
getFetchConfiguration()
Return the (mutable) fetch configuration for loading objects from this context.Seq
getIdentitySequence(ClassMetaData meta)
Returns aSeq
for the datastore identity values of the specified persistent class, or null if the class' identity cannot be represented as a sequence.boolean
getIgnoreChanges()
Whether to take into account changes in the transaction when executing a query or iterating an extent.InverseManager
getInverseManager()
Return the inverse manager in use.LifecycleEventManager
getLifecycleEventManager()
Give state managers access to the lifecycle event manager.int
getLifecycleListenerCallbackMode()
The callback mode for handling exceptions from lifecycle event listeners.int
getLockLevel(java.lang.Object o)
Return the lock level of the specified object.LockManager
getLockManager()
Return the lock manager in use.java.util.Collection
getManagedObjects()
Return a list of all managed instances.ManagedRuntime
getManagedRuntime()
Return the managed runtime in use.protected java.util.Collection
getManagedStates()
Return a copy of all managed state managers.boolean
getMultithreaded()
Whether the broker or its managed instances are used in a multithreaded environment.boolean
getNontransactionalRead()
Whether to allow nontransactional access to persistent state.boolean
getNontransactionalWrite()
Whether to allow nontransactional changes to persistent state.java.lang.Object
getObjectId(java.lang.Object obj)
Return the oid of the given instance.java.lang.Class<?>
getObjectIdType(java.lang.Class<?> cls)
Return the application or datastore identity class the given persistent class uses for object ids.protected java.util.Set<java.lang.Object>
getOperatingSet()
Gets the unmodifiable set of instances being operated.boolean
getOptimistic()
Whether to use optimistic transactional semantics.boolean
getOrderDirtyObjects()
Whether to maintain the order in which objects are dirtied forStoreContext.getDirtyObjects()
.java.util.Collection
getPendingTransactionalObjects()
Return a list of instances which will become transactional upon the next transaction.protected java.util.Collection
getPendingTransactionalStates()
Return a copy of all state managers which will become transactional upon the next transaction.java.util.Collection
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.boolean
getPrintParameters()
java.util.Map<java.lang.String,java.lang.Object>
getProperties()
Get current configuration property values used by this instance.int
getRestoreState()
Whether to restore an object's original state on rollback.boolean
getRetainState()
Whether objects retain their persistent state on transaction commit.java.lang.Throwable
getRollbackCause()
Returns the Throwable that caused the transaction to be marked for rollback.boolean
getRollbackOnly()
Return whether the current transaction has been marked for rollback.OpenJPAStateManager
getStateManager(java.lang.Object obj)
Return the state manager for the given instance.protected StateManagerImpl
getStateManagerImpl(java.lang.Object obj, boolean assertThisContext)
Return the state manager for the given instance, or null.protected StateManagerImpl
getStateManagerImplById(java.lang.Object oid, boolean allowNew)
Return the state manager for the given oid.DelegatingStoreManager
getStoreManager()
Return the store manager in use.java.util.Set<java.lang.String>
getSupportedProperties()
Gets the property names that can be used to corresponding setter methods of this receiver to set its value.boolean
getSuppressBatchOLELogging()
Return whether this Broker will generate verbose optimistic lock exceptions when batching operations.jakarta.transaction.Synchronization
getSynchronization()
boolean
getSyncWithManagedTransactions()
Whether to check for a global transaction upon every managed, non-transactional operation.java.util.Collection
getTransactionalObjects()
Return a list of current transaction instances.protected java.util.Collection<StateManagerImpl>
getTransactionalStates()
Return a copy of all transactional state managers.int
getTransactionListenerCallbackMode()
The callback mode for handling exceptions from transaction event listeners.java.util.Collection<java.lang.Object>
getTransactionListeners()
Gets an umodifiable collection of currently registered lsteners.java.util.Collection
getUpdatedTypes()
Return the set of classes for objects that have been modified in the current transaction.java.lang.Object
getUserObject(java.lang.Object key)
Get the value for the specified key from the map of user objects.Seq
getValueSequence(FieldMetaData fmd)
Returns aSeq
for the generated values of the specified field, or null if the field is not generated.java.lang.Object
getVersion(java.lang.Object obj)
Returns the current version indicator foro
.boolean
hasConnection()
Whether the broker has a dedicated connection based on the configured connection retain mode and transaction status.void
initialize(AbstractBrokerFactory factory, DelegatingStoreManager sm, boolean managed, int connMode, boolean fromDeserialization)
Initialize the persistence manager.void
initialize(AbstractBrokerFactory factory, DelegatingStoreManager sm, boolean managed, int connMode, boolean fromDeserialization, boolean fromWriteBehindCallback)
protected StateManagerImpl
initialize(StateManagerImpl sm, boolean load, FetchConfiguration fetch, java.lang.Object edata)
Initialize a newly-constructed state manager.boolean
isActive()
Whether a logical transaction is active.boolean
isCached(java.util.List<java.lang.Object> oids)
Indicate whether the oid can be found in the StoreContext's L1 cache or in the StoreManager cache.boolean
isClosed()
Whether the broker is closed.boolean
isCloseInvoked()
WhetherBroker.close()
has been invoked, though the broker might remain open until the current managed transaction completes.boolean
isDeleted(java.lang.Object obj)
Return whether the given object is deleted.boolean
isDetached(java.lang.Object obj)
Returnstrue
ifobj
is a detached object (one that can be reattached to aBroker
via a call toBroker.attach(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)
); otherwise returnsfalse
.boolean
isDetached(java.lang.Object obj, boolean find)
This method makes a best effort to determine if the provided object is detached.boolean
isDetachedNew()
Whether to treat relations to detached instances during persist operations as new or as pseudo-hollow instances.boolean
isDirty(java.lang.Object obj)
Return whether the given object is dirty.protected boolean
isFlushing()
boolean
isFromWriteBehindCallback()
boolean
isLoading(java.lang.Object o)
boolean
isManaged()
Whether this context is using managed transactions.boolean
isNew(java.lang.Object obj)
Return whether the given object is a newly-created instance registered withbroker
.boolean
isPersistent(java.lang.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(java.lang.Object obj)
Return whether the given object is transactional.void
lock()
Synchronizes on an internal lock if theMultithreaded
flag is set to true.void
lock(java.lang.Object obj, int level, int timeout, OpCallbacks call)
Ensure that the given instance is locked at the given lock level.void
lock(java.lang.Object obj, OpCallbacks call)
Ensure that the given instance is locked at the current lock level, as set in theFetchConfiguration
for the broker.void
lockAll(java.util.Collection objs, int level, int timeout, OpCallbacks call)
Ensure that the given instances are locked at the given lock level.void
lockAll(java.util.Collection objs, OpCallbacks call)
Ensure that the given instances are locked at the current lock level, as set in theFetchConfiguration
for the broker.Extent
newExtent(java.lang.Class type, boolean subclasses)
Return an extent of the given class, optionally including subclasses.java.lang.Object
newInstance(java.lang.Class cls)
Create a new instance of typecls
.protected java.util.Map<?,?>
newManagedObjectCache()
Create aMap
to be used for the primary managed object cache.java.lang.Object
newObjectId(java.lang.Class<?> cls, java.lang.Object val)
Create a new object id instance from the given value.Query
newQuery(java.lang.String lang, java.lang.Class cls, java.lang.Object query)
Create a new query from the given data, with the given candidate class and language.Query
newQuery(java.lang.String lang, java.lang.Object query)
Create a new query in the given language.protected QueryImpl
newQueryImpl(java.lang.String lang, StoreQuery sq)
Create a new query.protected StateManagerImpl
newStateManagerImpl(java.lang.Object oid, ClassMetaData meta)
Create a state manager for the given oid and metadata.void
nontransactional(java.lang.Object obj, OpCallbacks call)
Make the given object non-transactional.void
nontransactionalAll(java.util.Collection objs, OpCallbacks call)
Make the given objects nontransactional.void
persist(java.lang.Object obj, boolean explicit, OpCallbacks call)
Persist the given object.OpenJPAStateManager
persist(java.lang.Object obj, java.lang.Object id, boolean explicit, OpCallbacks call)
Persist the given object.OpenJPAStateManager
persist(java.lang.Object obj, java.lang.Object id, boolean explicit, OpCallbacks call, boolean fireEvent)
Persist the given object.OpenJPAStateManager
persist(java.lang.Object obj, java.lang.Object id, OpCallbacks call)
Make the given instance persistent.void
persist(java.lang.Object obj, OpCallbacks call)
Persist the given object.void
persistAll(java.util.Collection objs, boolean explicit, OpCallbacks call)
Persist the given objects.void
persistAll(java.util.Collection objs, OpCallbacks call)
Persist the given objects.void
popFetchConfiguration()
Pops the fetch configuration from the top of the stack, making the next one down the active one.void
preFlush()
Run pre-flush actions on transactional objects, including persistence-by-reachability, inverse relationship management, deletion of dependent instances, and instance callbacks.java.lang.Object
processArgument(java.lang.Object oid)
Process find argument.java.lang.Object
processReturn(java.lang.Object oid, OpenJPAStateManager sm)
Process operation return value.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.java.lang.Object
putUserObject(java.lang.Object key, java.lang.Object val)
Put the specified key-value pair into the map of user objects.void
refresh(java.lang.Object obj, OpCallbacks call)
Refresh the state of the given object.void
refreshAll(java.util.Collection objs, OpCallbacks call)
Refresh the state of the given objects.protected void
refreshInternal(java.lang.Object obj, OpCallbacks call)
Optimization for single-object refresh.protected void
refreshInternal(java.util.Collection objs, OpCallbacks call)
This method is called with the full set of objects reachable via cascade-refresh relations from the user-given instances.void
release(java.lang.Object obj, OpCallbacks call)
Release the given object from management.void
releaseAll(java.util.Collection objs, OpCallbacks call)
Release the given objects from management.void
releaseSavepoint()
Release the last set savepoint and any resources associated with it.void
releaseSavepoint(java.lang.String savepoint)
Release the savepoint and any resources associated with it.void
removeLifecycleListener(java.lang.Object listener)
Remove a listener for lifecycle-related events.void
removeTransactionListener(java.lang.Object tl)
Remove a listener for transaction-related events.void
retrieve(java.lang.Object obj, boolean dfgOnly, OpCallbacks call)
Immediately load the given object's persistent fields.void
retrieveAll(java.util.Collection objs, boolean dfgOnly, OpCallbacks call)
Retrieve the given objects' persistent state.void
rollback()
Rollback the current transaction.void
rollbackAndResume()
Issue a rollback and then start a new transaction.void
rollbackToSavepoint()
Rollback the current transaction to the last savepoint.void
rollbackToSavepoint(java.lang.String savepoint)
Rollback the current transaction to the given savepoint name.void
setAllowReferenceToSiblingContext(boolean allow)
Affirms if this context will allow its managed instances to refer instances that are managed by other contexts.void
setAuthentication(java.lang.String user, java.lang.String pass)
Set the persistence manager's authentication.void
setAutoClear(int val)
Whether objects clear when entering transactions.void
setAutoDetach(int detachFlags)
Sets automatic detachment option.void
setAutoDetach(int detachFlag, boolean on)
Bit flags marked inAutoDetach
which indicate when persistent managed objects should be automatically detached in-place.void
setCacheFinderQuery(boolean flag)
void
setCachePreparedQuery(boolean flag)
Sets whether this receiver will cache prepared queries during its lifetime.void
setConnectionFactory2Name(java.lang.String connectionFactory2Name)
Set the 'NonJTA' ConnectionFactoryName.void
setConnectionFactoryName(java.lang.String connectionFactoryName)
Set the 'JTA' ConnectionFactoryName.void
setDetachedNew(boolean isNew)
Whether to treat relations to detached instances as new.void
setDetachState(int mode)
Detach mode constant to determine which fields are part of the detached graph.void
setEvictFromDataCache(boolean evict)
Whether to also evict an object from the store cache when it is evicted through this broker.void
setIgnoreChanges(boolean val)
Whether to take into account changes in the transaction when executing a query or iterating an extent.void
setImplicitBehavior(OpCallbacks call, RuntimeExceptionTranslator ex)
Set the broker's behavior for implicit actions such as flushing, automatic detachment, and exceptions thrown by managed instances outside a broker operation.void
setLifecycleListenerCallbackMode(int mode)
The callback mode for handling exceptions from lifecycle event listeners.void
setMultithreaded(boolean multithreaded)
Whether the broker or its managed instances are used in a multithreaded environment.void
setNontransactionalRead(boolean val)
Whether to allow nontransactional access to persistent state.void
setNontransactionalWrite(boolean val)
Whether to allow nontransactional changes to persistent state.void
setOptimistic(boolean val)
Whether to use optimistic transactional semantics.void
setOrderDirtyObjects(boolean order)
Whether to maintain the order in which objects are dirtied forStoreContext.getDirtyObjects()
.void
setPopulateDataCache(boolean cache)
Whether to populate the store cache with objects used by this transaction.void
setPostLoadOnMerge(boolean allow)
Set totrue
if the merge operation should trigger a @PostLoad lifecycle event.void
setRestoreState(int val)
Whether to restore an object's original state on rollback.void
setRetainState(boolean val)
Whether objects retain their persistent state on transaction commit.void
setRollbackOnly()
Mark the current transaction for rollback.void
setRollbackOnly(java.lang.Throwable cause)
Mark the current transaction for rollback with the specified cause of the rollback.void
setSavepoint(java.lang.String name)
Set a transactional savepoint where operations after this savepoint will be rolled back.protected void
setStateManager(java.lang.Object id, StateManagerImpl sm, int status)
Set the cached StateManager for the instance that had the given oid.protected void
setStatusFlag(int flag)
Sets the given flag to the status.void
setSuppressBatchOLELogging(boolean b)
Set whether this Broker will generate verbose optimistic lock exceptions when batching operations.void
setSynchronization(jakarta.transaction.Synchronization sync)
void
setSyncWithManagedTransactions(boolean sync)
Whether to check for a global transaction upon every managed, non-transactional operation.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
setTransactionListenerCallbackMode(int mode)
The callback mode for handling exceptions from transaction event listeners.boolean
syncWithManagedTransaction()
Attempt to synchronize with a current managed transaction, returning true if successful, false if no managed transaction is active.void
transactional(java.lang.Object obj, boolean updateVersion, OpCallbacks call)
Make the given instances transactional.void
transactionalAll(java.util.Collection objs, boolean updateVersion, OpCallbacks call)
Make the given instances transactional.void
unlock()
Releases the internal lock.void
validateChanges()
Validate the changes made in this transaction, reporting any optimistic violations, constraint violations, etc.
-
-
-
Field Detail
-
FLUSH_INC
protected static final int FLUSH_INC
Incremental flush.- See Also:
- Constant Field Values
-
FLUSH_COMMIT
protected static final int FLUSH_COMMIT
Flush in preparation of commit.- See Also:
- Constant Field Values
-
FLUSH_ROLLBACK
protected static final int FLUSH_ROLLBACK
Flush to check consistency of cache, then immediately rollback changes.- See Also:
- Constant Field Values
-
FLUSH_LOGICAL
protected static final int FLUSH_LOGICAL
Run persistence-by-reachability and other flush-time operations without accessing the database.- See Also:
- Constant Field Values
-
-
Method Detail
-
setAuthentication
public void setAuthentication(java.lang.String user, java.lang.String pass)
Set the persistence manager's authentication. This is the first method called after construction.- Parameters:
user
- the username this broker represents; used when pooling brokers to make sure that a request to the factory for a connection with an explicit user is delegated to a suitable brokerpass
- the password for the above user
-
initialize
public void initialize(AbstractBrokerFactory factory, DelegatingStoreManager sm, boolean managed, int connMode, boolean fromDeserialization)
Initialize the persistence manager. This method is called automatically by the factory before use.- Parameters:
factory
- the factory used to create this brokersm
- a concrete StoreManager implementation to handle interaction with the data storemanaged
- the transaction modeconnMode
- the connection retain modefromDeserialization
- whether this call happened because of a deserialization or creation of a new BrokerImpl.
-
initialize
public void initialize(AbstractBrokerFactory factory, DelegatingStoreManager sm, boolean managed, int connMode, boolean fromDeserialization, boolean fromWriteBehindCallback)
-
getOperatingSet
protected java.util.Set<java.lang.Object> getOperatingSet()
Gets the unmodifiable set of instances being operated.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Overrides:
clone
in classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
-
newManagedObjectCache
protected java.util.Map<?,?> newManagedObjectCache()
Create aMap
to be used for the primary managed object cache. Maps oids to state managers. By default, this creates aReferenceMap
with soft values.
-
getBroker
public Broker getBroker()
Description copied from interface:StoreContext
Return the broker for this context, if possible. Note that a broker will be unavailable in remote contexts, and this method may return null.- Specified by:
getBroker
in interfaceStoreContext
-
setImplicitBehavior
public void setImplicitBehavior(OpCallbacks call, RuntimeExceptionTranslator ex)
Description copied from interface:Broker
Set the broker's behavior for implicit actions such as flushing, automatic detachment, and exceptions thrown by managed instances outside a broker operation. A broker's implicit behavior can only be set once; after the first invocation with non-null arguments, subsequent invocations of this method are ignored.- Specified by:
setImplicitBehavior
in interfaceBroker
-
getBrokerFactory
public BrokerFactory getBrokerFactory()
Description copied from interface:Broker
Return the factory that produced this broker.- Specified by:
getBrokerFactory
in interfaceBroker
-
getConfiguration
public OpenJPAConfiguration getConfiguration()
Description copied from interface:StoreContext
Return the configuration associated with this context.- Specified by:
getConfiguration
in interfaceStoreContext
-
getFetchConfiguration
public FetchConfiguration getFetchConfiguration()
Description copied from interface:StoreContext
Return the (mutable) fetch configuration for loading objects from this context.- Specified by:
getFetchConfiguration
in interfaceStoreContext
-
pushFetchConfiguration
public FetchConfiguration pushFetchConfiguration()
Description copied from interface:StoreContext
Pushes a new fetch configuration that inherits from the current fetch configuration onto a stack, and makes the new configuration the active one.- Specified by:
pushFetchConfiguration
in interfaceStoreContext
- Returns:
- the new fetch configuration
-
pushFetchConfiguration
public FetchConfiguration pushFetchConfiguration(FetchConfiguration fc)
Description copied from interface:StoreContext
Pushes the fetch configuration argument onto a stack, and makes the new configuration the active one.- Specified by:
pushFetchConfiguration
in interfaceStoreContext
- Returns:
- the new fetch configuration
-
popFetchConfiguration
public void popFetchConfiguration()
Description copied from interface:StoreContext
Pops the fetch configuration from the top of the stack, making the next one down the active one. This returns void to avoid confusion, since fetch configurations tend to be used in method-chaining patterns often.- Specified by:
popFetchConfiguration
in interfaceStoreContext
-
getConnectionRetainMode
public int getConnectionRetainMode()
Description copied from interface:Broker
Return the connection retain mode for this broker.- Specified by:
getConnectionRetainMode
in interfaceBroker
-
isManaged
public boolean isManaged()
Description copied from interface:StoreContext
Whether this context is using managed transactions.- Specified by:
isManaged
in interfaceStoreContext
-
getManagedRuntime
public ManagedRuntime getManagedRuntime()
Description copied from interface:Broker
Return the managed runtime in use.- Specified by:
getManagedRuntime
in interfaceBroker
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:StoreContext
Return the current thread's class loader at the time this context was obtained.- Specified by:
getClassLoader
in interfaceStoreContext
-
getStoreManager
public DelegatingStoreManager getStoreManager()
Description copied from interface:StoreContext
Return the store manager in use. This will be a wrapper around the native store manager, which you can retrieve viaDelegatingStoreManager.getInnermostDelegate()
.- Specified by:
getStoreManager
in interfaceStoreContext
-
getLockManager
public LockManager getLockManager()
Description copied from interface:StoreContext
Return the lock manager in use.- Specified by:
getLockManager
in interfaceStoreContext
-
getInverseManager
public InverseManager getInverseManager()
Description copied from interface:Broker
Return the inverse manager in use.- Specified by:
getInverseManager
in interfaceBroker
-
getConnectionUserName
public java.lang.String getConnectionUserName()
Description copied from interface:StoreContext
Return the connection user name.- Specified by:
getConnectionUserName
in interfaceStoreContext
-
getConnectionPassword
public java.lang.String getConnectionPassword()
Description copied from interface:StoreContext
Return the connection password.- Specified by:
getConnectionPassword
in interfaceStoreContext
-
getMultithreaded
public boolean getMultithreaded()
Description copied from interface:Broker
Whether the broker or its managed instances are used in a multithreaded environment.- Specified by:
getMultithreaded
in interfaceBroker
-
setMultithreaded
public void setMultithreaded(boolean multithreaded)
Description copied from interface:Broker
Whether the broker or its managed instances are used in a multithreaded environment.- Specified by:
setMultithreaded
in interfaceBroker
-
getIgnoreChanges
public boolean getIgnoreChanges()
Description copied from interface:Broker
Whether to take into account changes in the transaction when executing a query or iterating an extent.- Specified by:
getIgnoreChanges
in interfaceBroker
-
setIgnoreChanges
public void setIgnoreChanges(boolean val)
Description copied from interface:Broker
Whether to take into account changes in the transaction when executing a query or iterating an extent.- Specified by:
setIgnoreChanges
in interfaceBroker
-
getNontransactionalRead
public boolean getNontransactionalRead()
Description copied from interface:Broker
Whether to allow nontransactional access to persistent state.- Specified by:
getNontransactionalRead
in interfaceBroker
-
setNontransactionalRead
public void setNontransactionalRead(boolean val)
Description copied from interface:Broker
Whether to allow nontransactional access to persistent state.- Specified by:
setNontransactionalRead
in interfaceBroker
-
getNontransactionalWrite
public boolean getNontransactionalWrite()
Description copied from interface:Broker
Whether to allow nontransactional changes to persistent state.- Specified by:
getNontransactionalWrite
in interfaceBroker
-
setNontransactionalWrite
public void setNontransactionalWrite(boolean val)
Description copied from interface:Broker
Whether to allow nontransactional changes to persistent state.- Specified by:
setNontransactionalWrite
in interfaceBroker
-
getOptimistic
public boolean getOptimistic()
Description copied from interface:Broker
Whether to use optimistic transactional semantics.- Specified by:
getOptimistic
in interfaceBroker
-
setOptimistic
public void setOptimistic(boolean val)
Description copied from interface:Broker
Whether to use optimistic transactional semantics.- Specified by:
setOptimistic
in interfaceBroker
-
getRestoreState
public int getRestoreState()
Description copied from interface:Broker
Whether to restore an object's original state on rollback.- Specified by:
getRestoreState
in interfaceBroker
-
setRestoreState
public void setRestoreState(int val)
Description copied from interface:Broker
Whether to restore an object's original state on rollback.- Specified by:
setRestoreState
in interfaceBroker
-
getRetainState
public boolean getRetainState()
Description copied from interface:Broker
Whether objects retain their persistent state on transaction commit.- Specified by:
getRetainState
in interfaceBroker
-
setRetainState
public void setRetainState(boolean val)
Description copied from interface:Broker
Whether objects retain their persistent state on transaction commit.- Specified by:
setRetainState
in interfaceBroker
-
getAutoClear
public int getAutoClear()
Description copied from interface:Broker
Whether objects clear when entering transactions.- Specified by:
getAutoClear
in interfaceBroker
-
setAutoClear
public void setAutoClear(int val)
Description copied from interface:Broker
Whether objects clear when entering transactions.- Specified by:
setAutoClear
in interfaceBroker
-
getAutoDetach
public int getAutoDetach()
Description copied from interface:Broker
Bit flags marked inAutoDetach
which indicate when persistent managed objects should be automatically detached in-place.- Specified by:
getAutoDetach
in interfaceBroker
-
setAutoDetach
public void setAutoDetach(int detachFlags)
Sets automatic detachment option.
If the given flag containsAutoDetach.DETACH_NONE
option, then no other option can be specified.- Specified by:
setAutoDetach
in interfaceBroker
-
setAutoDetach
public void setAutoDetach(int detachFlag, boolean on)
Description copied from interface:Broker
Bit flags marked inAutoDetach
which indicate when persistent managed objects should be automatically detached in-place.- Specified by:
setAutoDetach
in interfaceBroker
-
getDetachState
public int getDetachState()
Description copied from interface:StoreContext
Detach mode constant to determine which fields are part of the detached graph. Defaults toDetachState.DETACH_LOADED
.- Specified by:
getDetachState
in interfaceStoreContext
-
setDetachState
public void setDetachState(int mode)
Description copied from interface:StoreContext
Detach mode constant to determine which fields are part of the detached graph. Defaults toDetachState.DETACH_LOADED
.- Specified by:
setDetachState
in interfaceStoreContext
-
isDetachedNew
public boolean isDetachedNew()
Description copied from interface:Broker
Whether to treat relations to detached instances during persist operations as new or as pseudo-hollow instances.- Specified by:
isDetachedNew
in interfaceBroker
-
setDetachedNew
public void setDetachedNew(boolean isNew)
Description copied from interface:Broker
Whether to treat relations to detached instances as new.- Specified by:
setDetachedNew
in interfaceBroker
-
getSyncWithManagedTransactions
public boolean getSyncWithManagedTransactions()
Description copied from interface:Broker
Whether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.- Specified by:
getSyncWithManagedTransactions
in interfaceBroker
-
setSyncWithManagedTransactions
public void setSyncWithManagedTransactions(boolean sync)
Description copied from interface:Broker
Whether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.- Specified by:
setSyncWithManagedTransactions
in interfaceBroker
-
getEvictFromDataCache
public boolean getEvictFromDataCache()
Description copied from interface:Broker
Whether to also evict an object from the store cache when it is evicted through this broker.- Specified by:
getEvictFromDataCache
in interfaceBroker
-
setEvictFromDataCache
public void setEvictFromDataCache(boolean evict)
Description copied from interface:Broker
Whether to also evict an object from the store cache when it is evicted through this broker.- Specified by:
setEvictFromDataCache
in interfaceBroker
-
getPopulateDataCache
public boolean getPopulateDataCache()
Description copied from interface:StoreContext
Whether objects accessed during this transaction will be added to the store cache. Defaults to true.- Specified by:
getPopulateDataCache
in interfaceStoreContext
-
setPopulateDataCache
public void setPopulateDataCache(boolean cache)
Description copied from interface:StoreContext
Whether to populate the store cache with objects used by this transaction. Defaults to true.- Specified by:
setPopulateDataCache
in interfaceStoreContext
-
isTrackChangesByType
public boolean isTrackChangesByType()
Description copied from interface:StoreContext
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.- Specified by:
isTrackChangesByType
in interfaceStoreContext
-
setTrackChangesByType
public void setTrackChangesByType(boolean largeTransaction)
Description copied from interface:StoreContext
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. Upon transaction commit the data cache will have to more aggressively flush objects. The store cache will have to flush instances of objects for each class of object modified during the transaction. A side benefit of large transaction mode is that smaller update messages can be used forRemoteCommitEvent
s. Defaults to false.- Specified by:
setTrackChangesByType
in interfaceStoreContext
-
getUserObject
public java.lang.Object getUserObject(java.lang.Object key)
Description copied from interface:Broker
Get the value for the specified key from the map of user objects.- Specified by:
getUserObject
in interfaceBroker
-
putUserObject
public java.lang.Object putUserObject(java.lang.Object key, java.lang.Object val)
Description copied from interface:Broker
Put the specified key-value pair into the map of user objects. Use a value of null to remove the key.- Specified by:
putUserObject
in interfaceBroker
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Get current configuration property values used by this instance. This values are combination of the current configuration values overwritten by values maintained by this instance such as Optimistic flag.- Specified by:
getProperties
in interfaceBroker
- Returns:
- the changed properties
-
getSupportedProperties
public java.util.Set<java.lang.String> getSupportedProperties()
Gets the property names that can be used to corresponding setter methods of this receiver to set its value.- Specified by:
getSupportedProperties
in interfaceBroker
-
addLifecycleListener
public void addLifecycleListener(java.lang.Object listener, java.lang.Class[] classes)
Description copied from interface:Broker
Register a listener for lifecycle-related events on the specified classes. If the classes are null, all events will be propagated to the listener.- Specified by:
addLifecycleListener
in interfaceBroker
-
removeLifecycleListener
public void removeLifecycleListener(java.lang.Object listener)
Description copied from interface:Broker
Remove a listener for lifecycle-related events.- Specified by:
removeLifecycleListener
in interfaceBroker
-
getLifecycleListenerCallbackMode
public int getLifecycleListenerCallbackMode()
Description copied from interface:Broker
The callback mode for handling exceptions from lifecycle event listeners.- Specified by:
getLifecycleListenerCallbackMode
in interfaceBroker
-
setLifecycleListenerCallbackMode
public void setLifecycleListenerCallbackMode(int mode)
Description copied from interface:Broker
The callback mode for handling exceptions from lifecycle event listeners.- Specified by:
setLifecycleListenerCallbackMode
in interfaceBroker
-
getLifecycleEventManager
public LifecycleEventManager getLifecycleEventManager()
Give state managers access to the lifecycle event manager.- Specified by:
getLifecycleEventManager
in interfaceBroker
-
addTransactionListener
public void addTransactionListener(java.lang.Object tl)
Description copied from interface:Broker
Register a listener for transaction-related events.- Specified by:
addTransactionListener
in interfaceBroker
-
removeTransactionListener
public void removeTransactionListener(java.lang.Object tl)
Description copied from interface:Broker
Remove a listener for transaction-related events.- Specified by:
removeTransactionListener
in interfaceBroker
-
getTransactionListeners
public java.util.Collection<java.lang.Object> getTransactionListeners()
Description copied from interface:Broker
Gets an umodifiable collection of currently registered lsteners.- Specified by:
getTransactionListeners
in interfaceBroker
-
getTransactionListenerCallbackMode
public int getTransactionListenerCallbackMode()
Description copied from interface:Broker
The callback mode for handling exceptions from transaction event listeners.- Specified by:
getTransactionListenerCallbackMode
in interfaceBroker
-
setTransactionListenerCallbackMode
public void setTransactionListenerCallbackMode(int mode)
Description copied from interface:Broker
The callback mode for handling exceptions from transaction event listeners.- Specified by:
setTransactionListenerCallbackMode
in interfaceBroker
-
setSuppressBatchOLELogging
public void setSuppressBatchOLELogging(boolean b)
Set whether this Broker will generate verbose optimistic lock exceptions when batching operations. Defaults to true.
-
getSuppressBatchOLELogging
public boolean getSuppressBatchOLELogging()
Return whether this Broker will generate verbose optimistic lock exceptions when batching operations.
-
find
public java.lang.Object find(java.lang.Object oid, boolean validate, FindCallbacks call)
Description copied from interface:StoreContext
Find the persistence object with the given oid. Ifvalidate
is true, the broker will check the store for the object, and return null if it does not exist. Ifvalidate
is false, this method never returns null. The broker will either return its cached instance, attempt to create a hollow instance, or throw anObjectNotFoundException
if unable to return a hollow instance.- Specified by:
find
in interfaceStoreContext
validate
- if true, validate that the instance exists in the store and load fetch group fields, otherwise return any cached or hollow instance
-
find
public java.lang.Object find(java.lang.Object oid, FetchConfiguration fetch, java.util.BitSet exclude, java.lang.Object edata, int flags)
Description copied from interface:StoreContext
Return the object with the given oid. If present, the cached instance will be returned. Otherwise, the instance will be initialized through the store as usual; however, in this case the store will be passed the given execution data, and the system will load the object according to the given fetch configuration (or the context's configuration, if the given one is null). Fields can optionally be excluded from required loading using theexclude
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 givenOID_XXX
flags.- Specified by:
find
in interfaceStoreContext
-
find
protected java.lang.Object find(java.lang.Object oid, FetchConfiguration fetch, java.util.BitSet exclude, java.lang.Object edata, int flags, FindCallbacks call)
Internal finder.
-
initialize
protected StateManagerImpl initialize(StateManagerImpl sm, boolean load, FetchConfiguration fetch, java.lang.Object edata)
Initialize a newly-constructed state manager.
-
findAll
public java.lang.Object[] findAll(java.util.Collection oids, boolean validate, FindCallbacks call)
Description copied from interface:StoreContext
Return the objects with the given oids.- Specified by:
findAll
in interfaceStoreContext
- Parameters:
oids
- the oids of the objects to return- Returns:
- the objects that were looked up, in the same order as the oids parameter
- See Also:
StoreContext.find(Object,boolean,FindCallbacks)
-
findAll
public java.lang.Object[] findAll(java.util.Collection oids, FetchConfiguration fetch, java.util.BitSet exclude, java.lang.Object edata, int flags)
Description copied from interface:StoreContext
Return the objects with the given oids.- Specified by:
findAll
in interfaceStoreContext
- See Also:
StoreContext.find(Object,FetchConfiguration,BitSet,Object,int)
-
findAll
protected java.lang.Object[] findAll(java.util.Collection oids, FetchConfiguration fetch, java.util.BitSet exclude, java.lang.Object edata, int flags, FindCallbacks call)
Internal finder.
-
isLoading
public boolean isLoading(java.lang.Object o)
-
findCached
public java.lang.Object findCached(java.lang.Object oid, FindCallbacks call)
Description copied from interface:StoreContext
Return the instance for the given oid/object , or null if not found in the L1 cache.- Specified by:
findCached
in interfaceStoreContext
- Parameters:
oid
- the object's id- Returns:
- the cached object, or null if not cached
-
getObjectIdType
public java.lang.Class<?> getObjectIdType(java.lang.Class<?> cls)
Description copied from interface:StoreContext
Return the application or datastore identity class the given persistent class uses for object ids.- Specified by:
getObjectIdType
in interfaceStoreContext
-
newObjectId
public java.lang.Object newObjectId(java.lang.Class<?> cls, java.lang.Object val)
Description copied from interface:StoreContext
Create a new object id instance from the given value.- Specified by:
newObjectId
in interfaceStoreContext
- Parameters:
cls
- the persistent class that uses this identity valueval
- an object id instance, stringified object id, or primary key value
-
newStateManagerImpl
protected StateManagerImpl newStateManagerImpl(java.lang.Object oid, ClassMetaData meta)
Create a state manager for the given oid and metadata.
-
begin
public void begin()
Description copied from interface:Broker
Begin a transaction.
-
beginStore
public void beginStore()
Description copied from interface:StoreContext
Begin a data store transaction.- Specified by:
beginStore
in interfaceStoreContext
-
commit
public void commit()
Description copied from interface:Broker
Commit the current transaction.
-
rollback
public void rollback()
Description copied from interface:Broker
Rollback the current transaction.
-
syncWithManagedTransaction
public boolean syncWithManagedTransaction()
Description copied from interface:Broker
Attempt to synchronize with a current managed transaction, returning true if successful, false if no managed transaction is active.- Specified by:
syncWithManagedTransaction
in interfaceBroker
-
commitAndResume
public void commitAndResume()
Description copied from interface:Broker
Issue a commit and then start a new transaction. This is identical to:broker.commit (); broker.begin ();
except that the broker's internal atomic lock is utilized, so this method can be safely executed from multiple threads.- Specified by:
commitAndResume
in interfaceBroker
- See Also:
Broker.commit()
,Broker.begin()
-
rollbackAndResume
public void rollbackAndResume()
Description copied from interface:Broker
Issue a rollback and then start a new transaction. This is identical to:broker.rollback (); broker.begin ();
except that the broker's internal atomic lock is utilized, so this method can be safely executed from multiple threads.- Specified by:
rollbackAndResume
in interfaceBroker
- See Also:
Broker.rollback()
,Broker.begin()
-
getRollbackOnly
public boolean getRollbackOnly()
Description copied from interface:Broker
Return whether the current transaction has been marked for rollback.- Specified by:
getRollbackOnly
in interfaceBroker
-
getRollbackCause
public java.lang.Throwable getRollbackCause()
Description copied from interface:Broker
Returns the Throwable that caused the transaction to be marked for rollback.- Specified by:
getRollbackCause
in interfaceBroker
- Returns:
- the Throwable, or null if none was given
-
setRollbackOnly
public void setRollbackOnly()
Description copied from interface:Broker
Mark the current transaction for rollback.- Specified by:
setRollbackOnly
in interfaceBroker
-
setRollbackOnly
public void setRollbackOnly(java.lang.Throwable cause)
Description copied from interface:Broker
Mark the current transaction for rollback with the specified cause of the rollback.- Specified by:
setRollbackOnly
in interfaceBroker
-
setSavepoint
public void setSavepoint(java.lang.String name)
Description copied from interface:Broker
Set a transactional savepoint where operations after this savepoint will be rolled back.- Specified by:
setSavepoint
in interfaceBroker
-
releaseSavepoint
public void releaseSavepoint()
Description copied from interface:Broker
Release the last set savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.- Specified by:
releaseSavepoint
in interfaceBroker
-
releaseSavepoint
public void releaseSavepoint(java.lang.String savepoint)
Description copied from interface:Broker
Release the savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.- Specified by:
releaseSavepoint
in interfaceBroker
-
rollbackToSavepoint
public void rollbackToSavepoint()
Description copied from interface:Broker
Rollback the current transaction to the last savepoint. Savepoints set after this one will become invalid.- Specified by:
rollbackToSavepoint
in interfaceBroker
-
rollbackToSavepoint
public void rollbackToSavepoint(java.lang.String savepoint)
Description copied from interface:Broker
Rollback the current transaction to the given savepoint name. Savepoints set after this one will become invalid.- Specified by:
rollbackToSavepoint
in interfaceBroker
-
setStatusFlag
protected void setStatusFlag(int flag)
Sets the given flag to the status.- Since:
- 2.3.0
-
clearStatusFlag
protected void clearStatusFlag(int flag)
Clears the given flag from the status.- Since:
- 2.3.0
-
flush
public void flush()
Description copied from interface:Broker
Flush all transactional instances to the data store. This method may set the rollback only flag on the current transaction if it encounters an error.
-
preFlush
public void preFlush()
Description copied from interface:Broker
Run pre-flush actions on transactional objects, including persistence-by-reachability, inverse relationship management, deletion of dependent instances, and instance callbacks. Transaction listeners are not invoked.
-
validateChanges
public void validateChanges()
Description copied from interface:Broker
Validate the changes made in this transaction, reporting any optimistic violations, constraint violations, etc. In a datastore transaction or a flushed optimistic transaction, this method will act just likeBroker.flush()
. In an optimistic transaction that has not yet begun a datastore-level transaction, however, it will only report exceptions that would occur on flush, without retaining any datastore resources.- Specified by:
validateChanges
in interfaceBroker
-
isActive
public boolean isActive()
Description copied from interface:StoreContext
Whether a logical transaction is active.- Specified by:
isActive
in interfaceStoreContext
-
isStoreActive
public boolean isStoreActive()
Description copied from interface:StoreContext
Whether a data store transaction is active.- Specified by:
isStoreActive
in interfaceStoreContext
-
beginOperation
public boolean beginOperation(boolean syncTrans)
Description copied from interface:Broker
Begin a logical operation. This indicates to the broker the granularity of an operation which may require pre/post operation side-effects, such as non-tx detach. Will lock the broker until theBroker.endOperation()
is called.- Specified by:
beginOperation
in interfaceBroker
- Parameters:
syncTrans
- whether instances may be loaded/modified during this operation requiring a re-check of global tx- Returns:
- whether this is the outermost operation on the stack
-
endOperation
public boolean endOperation()
Mark the operation over. If outermost caller of stack, returns true and will detach managed instances if necessary.- Specified by:
endOperation
in interfaceBroker
- Returns:
- whether this is the outermost operation on the stack
-
getSynchronization
public jakarta.transaction.Synchronization getSynchronization()
-
setSynchronization
public void setSynchronization(jakarta.transaction.Synchronization sync)
-
beforeCompletion
public void beforeCompletion()
- Specified by:
beforeCompletion
in interfacejakarta.transaction.Synchronization
-
afterCompletion
public void afterCompletion(int status)
- Specified by:
afterCompletion
in interfacejakarta.transaction.Synchronization
-
flush
protected void flush(int reason)
Flush the transactional state to the data store. Subclasses that customize commit behavior should override this method. The method assumes that the persistence manager is locked, is not closed, and has an active transaction.- Parameters:
reason
- one ofFLUSH_INC
,FLUSH_COMMIT
,FLUSH_ROLLBACK
, orFLUSH_LOGICAL
- Since:
- 0.2.5
-
endTransaction
protected void endTransaction(int status)
End the current transaction, making appropriate state transitions.
-
persist
public void persist(java.lang.Object obj, OpCallbacks call)
Description copied from interface:Broker
Persist the given object.
-
persist
public OpenJPAStateManager persist(java.lang.Object obj, java.lang.Object id, OpCallbacks call)
Description copied from interface:Broker
Make the given instance persistent. Unlike other persist operations, this method does not immediately cascade to fields markedValueMetaData.CASCADE_IMMEDIATE
.
-
persistAll
public void persistAll(java.util.Collection objs, OpCallbacks call)
Description copied from interface:Broker
Persist the given objects.- Specified by:
persistAll
in interfaceBroker
-
persistAll
public void persistAll(java.util.Collection objs, boolean explicit, OpCallbacks call)
Persist the given objects. Indicate whether this was an explicit persist (PNEW) or a provisonal persist (PNEWPROVISIONAL).
-
persist
public void persist(java.lang.Object obj, boolean explicit, OpCallbacks call)
Persist the given object. Indicate whether this was an explicit persist (PNEW) or a provisonal persist (PNEWPROVISIONAL)
-
persist
public OpenJPAStateManager persist(java.lang.Object obj, java.lang.Object id, boolean explicit, OpCallbacks call)
Persist the given object. Indicate whether this was an explicit persist (PNEW) or a provisonal persist (PNEWPROVISIONAL). SeeBroker
for details on this method.
-
persist
public OpenJPAStateManager persist(java.lang.Object obj, java.lang.Object id, boolean explicit, OpCallbacks call, boolean fireEvent)
Persist the given object. Indicate whether this was an explicit persist (PNEW) or a provisonal persist (PNEWPROVISIONAL). SeeBroker
for details on this method.
-
deleteAll
public void deleteAll(java.util.Collection objs, OpCallbacks call)
Description copied from interface:Broker
Delete the given objects.
-
delete
public void delete(java.lang.Object obj, OpCallbacks call)
Description copied from interface:Broker
Delete the given object.
-
releaseAll
public void releaseAll(java.util.Collection objs, OpCallbacks call)
Description copied from interface:Broker
Release the given objects from management. This operation is not recursive.- Specified by:
releaseAll
in interfaceBroker
-
release
public void release(java.lang.Object obj, OpCallbacks call)
Description copied from interface:Broker
Release the given object from management. This operation is not recursive.
-
embed
public OpenJPAStateManager embed(java.lang.Object obj, java.lang.Object id, OpenJPAStateManager owner, ValueMetaData ownerMeta)
Description copied from interface:StoreContext
Make the given instance embedded.- Specified by:
embed
in interfaceStoreContext
- Parameters:
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 embedded- Returns:
- the state manager for the embedded instance
-
refreshAll
public void refreshAll(java.util.Collection objs, OpCallbacks call)
Description copied from interface:Broker
Refresh the state of the given objects.- Specified by:
refreshAll
in interfaceBroker
-
refresh
public void refresh(java.lang.Object obj, OpCallbacks call)
Description copied from interface:Broker
Refresh the state of the given object.
-
refreshInternal
protected void refreshInternal(java.util.Collection objs, OpCallbacks call)
This method is called with the full set of objects reachable via cascade-refresh relations from the user-given instances.
-
refreshInternal
protected void refreshInternal(java.lang.Object obj, OpCallbacks call)
Optimization for single-object refresh.
-
retrieveAll
public void retrieveAll(java.util.Collection objs, boolean dfgOnly, OpCallbacks call)
Description copied from interface:StoreContext
Retrieve the given objects' persistent state. Unmanaged targets are ignored.- Specified by:
retrieveAll
in interfaceStoreContext
dfgOnly
- indicator as to whether to retrieve only fields- See Also:
StoreContext.retrieve(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)
-
retrieve
public void retrieve(java.lang.Object obj, boolean dfgOnly, OpCallbacks call)
Description copied from interface:StoreContext
Immediately load the given object's persistent fields. One might use this action to make sure that an instance's fields are loaded before transitioning it to transient. Note that this action is not recursive. Any related objects that are loaded will not necessarily have their fields loaded. Unmanaged target is ignored.- Specified by:
retrieve
in interfaceStoreContext
dfgOnly
- indicator as to whether to retrieve only fields in the current fetch groups, or all fields- See Also:
StoreContext.retrieve(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)
-
evictAll
public void evictAll(OpCallbacks call)
Description copied from interface:Broker
Evict all clean objects.
-
evictAll
public void evictAll(java.util.Collection objs, OpCallbacks call)
Description copied from interface:Broker
Evict the given objects.
-
evictAll
public void evictAll(Extent extent, OpCallbacks call)
Description copied from interface:Broker
Evict all persistent-clean and persistent-nontransactional instances in the givenExtent
.
-
evict
public void evict(java.lang.Object obj, OpCallbacks call)
Description copied from interface:Broker
Evict the given object.
-
detach
public java.lang.Object detach(java.lang.Object obj, OpCallbacks call)
Description copied from interface:Broker
Detach the specified object from the broker.
-
detachAll
public java.lang.Object[] detachAll(java.util.Collection objs, OpCallbacks call)
Description copied from interface:Broker
Detach the specified objects from the broker. The objects returned can be manipulated and re-attached withBroker.attachAll(java.util.Collection, boolean, org.apache.openjpa.kernel.OpCallbacks)
. The detached instances will be unmanaged copies of the specified parameters, and are suitable for serialization and manipulation outside of a OpenJPA environment. When detaching instances, only fields in the currentFetchConfiguration
will be traversed. Thus, to detach a graph of objects, relations to other persistent instances must either be in thedefault-fetch-group
, or in the current customFetchConfiguration
.
-
detachAll
public void detachAll(OpCallbacks call)
Description copied from interface:Broker
Detach all objects in place. A flush will be performed before detaching the entities.
-
detachAll
public void detachAll(OpCallbacks call, boolean flush)
Description copied from interface:Broker
Detach all objects in place, with the option of performing a flush before doing the detachment.
-
attach
public java.lang.Object attach(java.lang.Object obj, boolean copyNew, OpCallbacks call)
Description copied from interface:Broker
Import the specified detached object into the broker.
-
attachAll
public java.lang.Object[] attachAll(java.util.Collection objs, boolean copyNew, OpCallbacks call)
Description copied from interface:Broker
Import the specified objects into the broker. Instances that were previously detached from this or another broker will have their changed merged into the persistent instances. Instances that are new will be persisted as new instances.
-
nontransactionalAll
public void nontransactionalAll(java.util.Collection objs, OpCallbacks call)
Description copied from interface:StoreContext
Make the given objects nontransactional.- Specified by:
nontransactionalAll
in interfaceStoreContext
-
nontransactional
public void nontransactional(java.lang.Object obj, OpCallbacks call)
Description copied from interface:StoreContext
Make the given object non-transactional.- Specified by:
nontransactional
in interfaceStoreContext
-
transactionalAll
public void transactionalAll(java.util.Collection objs, boolean updateVersion, OpCallbacks call)
Make the given instances transactional.- Specified by:
transactionalAll
in interfaceStoreContext
- Parameters:
objs
- instances to make transactionalupdateVersion
- if true, the instance's version will be incremented at the next flush
-
transactional
public void transactional(java.lang.Object obj, boolean updateVersion, OpCallbacks call)
Make the given instances transactional.- Specified by:
transactional
in interfaceStoreContext
- Parameters:
obj
- instance to make transactionalupdateVersion
- if true, the instance's version will be incremented at the next flush
-
newExtent
public Extent newExtent(java.lang.Class type, boolean subclasses)
Description copied from interface:Broker
Return an extent of the given class, optionally including subclasses.
-
extentIterator
public java.util.Iterator extentIterator(java.lang.Class type, boolean subclasses, FetchConfiguration fetch, boolean ignoreChanges)
Description copied from interface:StoreContext
Return an iterator over all instances of the given type. The iterator should be closed withImplHelper.close(java.lang.Object)
when no longer needed. This method delegates toStoreManager.executeExtent(org.apache.openjpa.meta.ClassMetaData, boolean, org.apache.openjpa.kernel.FetchConfiguration)
.- Specified by:
extentIterator
in interfaceStoreContext
-
newQuery
public Query newQuery(java.lang.String lang, java.lang.Class cls, java.lang.Object query)
Description copied from interface:Broker
Create a new query from the given data, with the given candidate class and language.
-
newQuery
public Query newQuery(java.lang.String lang, java.lang.Object query)
Description copied from interface:Broker
Create a new query in the given language.
-
newQueryImpl
protected QueryImpl newQueryImpl(java.lang.String lang, StoreQuery sq)
Create a new query.
-
getIdentitySequence
public Seq getIdentitySequence(ClassMetaData meta)
Description copied from interface:Broker
Returns aSeq
for the datastore identity values of the specified persistent class, or null if the class' identity cannot be represented as a sequence.- Specified by:
getIdentitySequence
in interfaceBroker
-
getValueSequence
public Seq getValueSequence(FieldMetaData fmd)
Description copied from interface:Broker
Returns aSeq
for the generated values of the specified field, or null if the field is not generated.- Specified by:
getValueSequence
in interfaceBroker
-
lock
public void lock(java.lang.Object obj, OpCallbacks call)
Description copied from interface:Broker
Ensure that the given instance is locked at the current lock level, as set in theFetchConfiguration
for the broker.
-
lock
public void lock(java.lang.Object obj, int level, int timeout, OpCallbacks call)
Description copied from interface:Broker
Ensure that the given instance is locked at the given lock level.
-
lockAll
public void lockAll(java.util.Collection objs, OpCallbacks call)
Description copied from interface:Broker
Ensure that the given instances are locked at the current lock level, as set in theFetchConfiguration
for the broker.
-
lockAll
public void lockAll(java.util.Collection objs, int level, int timeout, OpCallbacks call)
Description copied from interface:Broker
Ensure that the given instances are locked at the given lock level.
-
cancelAll
public boolean cancelAll()
Description copied from interface:Broker
Cancel all pending data store statements. If statements are cancelled while a flush is in progress, the transaction rollback only flag will be set.
-
getConnection
public java.lang.Object getConnection()
Description copied from interface:StoreContext
Return the connection in use by the context, or a new connection if none.- Specified by:
getConnection
in interfaceStoreContext
-
hasConnection
public boolean hasConnection()
Description copied from interface:StoreContext
Whether the broker has a dedicated connection based on the configured connection retain mode and transaction status.- Specified by:
hasConnection
in interfaceStoreContext
-
getManagedObjects
public java.util.Collection getManagedObjects()
Description copied from interface:StoreContext
Return a list of all managed instances.- Specified by:
getManagedObjects
in interfaceStoreContext
-
getTransactionalObjects
public java.util.Collection getTransactionalObjects()
Description copied from interface:StoreContext
Return a list of current transaction instances.- Specified by:
getTransactionalObjects
in interfaceStoreContext
-
getPendingTransactionalObjects
public java.util.Collection getPendingTransactionalObjects()
Description copied from interface:StoreContext
Return a list of instances which will become transactional upon the next transaction.- Specified by:
getPendingTransactionalObjects
in interfaceStoreContext
-
getDirtyObjects
public java.util.Collection getDirtyObjects()
Description copied from interface:StoreContext
Return a list of current dirty instances.- Specified by:
getDirtyObjects
in interfaceStoreContext
-
getOrderDirtyObjects
public boolean getOrderDirtyObjects()
Description copied from interface:StoreContext
Whether to maintain the order in which objects are dirtied forStoreContext.getDirtyObjects()
. Default is the store manager's decision.- Specified by:
getOrderDirtyObjects
in interfaceStoreContext
-
setOrderDirtyObjects
public void setOrderDirtyObjects(boolean order)
Description copied from interface:StoreContext
Whether to maintain the order in which objects are dirtied forStoreContext.getDirtyObjects()
. Default is the store manager's decision.- Specified by:
setOrderDirtyObjects
in interfaceStoreContext
-
getManagedStates
protected java.util.Collection getManagedStates()
Return a copy of all managed state managers.
-
getTransactionalStates
protected java.util.Collection<StateManagerImpl> getTransactionalStates()
Return a copy of all transactional state managers.
-
getDirtyStates
protected java.util.Collection getDirtyStates()
Return a copy of all dirty state managers.
-
getPendingTransactionalStates
protected java.util.Collection getPendingTransactionalStates()
Return a copy of all state managers which will become transactional upon the next transaction.
-
setStateManager
protected void setStateManager(java.lang.Object id, StateManagerImpl sm, int status)
Set the cached StateManager for the instance that had the given oid. This method must not be called multiple times for new instances.- Parameters:
id
- the id previously used by the instancesm
- the state manager for the instance; if the state manager is transient, we'll stop managing the instance; if it has updated its oid, we'll re-cache under the new oidstatus
- one of our STATUS constants describing why we're setting the state manager
-
dirtyType
public void dirtyType(java.lang.Class cls)
Description copied from interface:Broker
Mark the given class as dirty within the current transaction.
-
getPersistedTypes
public java.util.Collection getPersistedTypes()
Description copied from interface:StoreContext
Return the set of classes that have been made persistent in the current transaction.- Specified by:
getPersistedTypes
in interfaceStoreContext
-
getUpdatedTypes
public java.util.Collection getUpdatedTypes()
Description copied from interface:StoreContext
Return the set of classes for objects that have been modified in the current transaction.- Specified by:
getUpdatedTypes
in interfaceStoreContext
-
getDeletedTypes
public java.util.Collection getDeletedTypes()
Description copied from interface:StoreContext
Return the set of classes that have been deleted in the current transaction.- Specified by:
getDeletedTypes
in interfaceStoreContext
-
isClosed
public boolean isClosed()
Description copied from interface:Broker
Whether the broker is closed.
-
isCloseInvoked
public boolean isCloseInvoked()
Description copied from interface:Broker
WhetherBroker.close()
has been invoked, though the broker might remain open until the current managed transaction completes.- Specified by:
isCloseInvoked
in interfaceBroker
-
close
public void close()
Description copied from interface:Broker
Close the broker.
-
free
protected void free()
Free the resources used by this persistence manager.
-
lock
public void lock()
Description copied from interface:StoreContext
Synchronizes on an internal lock if theMultithreaded
flag is set to true. Make sure to callStoreContext.unlock()
in a finally clause of the same method.- Specified by:
lock
in interfaceStoreContext
-
unlock
public void unlock()
Description copied from interface:StoreContext
Releases the internal lock.- Specified by:
unlock
in interfaceStoreContext
-
newInstance
public java.lang.Object newInstance(java.lang.Class cls)
Description copied from interface:Broker
Create a new instance of typecls
. Ifcls
is an interface or an abstract class whose abstract methods follow the JavaBeans convention, this method will create a concrete implementation according to the metadata that defines the class. Otherwise, ifcls
is a managed type, this will return an instance of the specified class.- Specified by:
newInstance
in interfaceBroker
-
getObjectId
public java.lang.Object getObjectId(java.lang.Object obj)
Description copied from interface:StoreContext
Return the oid of the given instance.- Specified by:
getObjectId
in interfaceStoreContext
-
getLockLevel
public int getLockLevel(java.lang.Object o)
Description copied from interface:StoreContext
Return the lock level of the specified object.- Specified by:
getLockLevel
in interfaceStoreContext
-
getVersion
public java.lang.Object getVersion(java.lang.Object obj)
Description copied from interface:StoreContext
Returns the current version indicator foro
.- Specified by:
getVersion
in interfaceStoreContext
-
isDirty
public boolean isDirty(java.lang.Object obj)
Description copied from interface:StoreContext
Return whether the given object is dirty.- Specified by:
isDirty
in interfaceStoreContext
-
isTransactional
public boolean isTransactional(java.lang.Object obj)
Description copied from interface:StoreContext
Return whether the given object is transactional.- Specified by:
isTransactional
in interfaceStoreContext
-
isPersistent
public boolean isPersistent(java.lang.Object obj)
Description copied from interface:StoreContext
Return whether the given object is persistent.- Specified by:
isPersistent
in interfaceStoreContext
-
isNew
public boolean isNew(java.lang.Object obj)
Description copied from interface:StoreContext
Return whether the given object is a newly-created instance registered withbroker
.- Specified by:
isNew
in interfaceStoreContext
-
isDeleted
public boolean isDeleted(java.lang.Object obj)
Description copied from interface:StoreContext
Return whether the given object is deleted.- Specified by:
isDeleted
in interfaceStoreContext
-
isDetached
public boolean isDetached(java.lang.Object obj)
Description copied from interface:Broker
Returnstrue
ifobj
is a detached object (one that can be reattached to aBroker
via a call toBroker.attach(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)
); otherwise returnsfalse
.- Specified by:
isDetached
in interfaceBroker
-
isDetached
public boolean isDetached(java.lang.Object obj, boolean find)
This method makes a best effort to determine if the provided object is detached.- Parameters:
find
- - If true, as a last resort this method will check whether or not the provided object exists in the DB. If it is in the DB, the provided object is detached.- Returns:
- - True if the provided obj is detached, false otherwise.
-
getStateManager
public OpenJPAStateManager getStateManager(java.lang.Object obj)
Description copied from interface:StoreContext
Return the state manager for the given instance. Includes objects made persistent in the current transaction. Ifobj
is not a managed type or is managed by another context, throw an exception.- Specified by:
getStateManager
in interfaceStoreContext
-
getStateManagerImpl
protected StateManagerImpl getStateManagerImpl(java.lang.Object obj, boolean assertThisContext)
Return the state manager for the given instance, or null.- Parameters:
assertThisContext
- if true, thow an exception if the given object is managed by another broker
-
getStateManagerImplById
protected StateManagerImpl getStateManagerImplById(java.lang.Object oid, boolean allowNew)
Return the state manager for the given oid.- Parameters:
allowNew
- if true, objects made persistent in the current transaction will be included in the search; if multiple new objects match the given oid, it is undefined which will be returned
-
assertPersistenceCapable
protected PersistenceCapable assertPersistenceCapable(java.lang.Object obj)
Return the given instance as aPersistenceCapable
. If the instance is not manageable throw the proper exception.
-
assertOpen
public void assertOpen()
Throw an exception if the context is closed. The exact message and content of the exception varies whether TRACE is enabled or not.- Specified by:
assertOpen
in interfaceBroker
-
assertActiveTransaction
public void assertActiveTransaction()
Description copied from interface:Broker
Throw an exception if there is no active transaction.- Specified by:
assertActiveTransaction
in interfaceBroker
-
assertNontransactionalRead
public void assertNontransactionalRead()
Description copied from interface:Broker
Throw an exception if there is no transaction active and nontransactional reading is not enabled.- Specified by:
assertNontransactionalRead
in interfaceBroker
-
assertWriteOperation
public void assertWriteOperation()
Description copied from interface:Broker
Throw an exception if a write operation is not permitted (there is no active transaction and nontransactional writing is not enabled).- Specified by:
assertWriteOperation
in interfaceBroker
-
processArgument
public java.lang.Object processArgument(java.lang.Object oid)
Description copied from interface:FindCallbacks
Process find argument. Throw properOpenJPAException
for illegal value.- Specified by:
processArgument
in interfaceFindCallbacks
- Returns:
- the id to look up, or null to ignore this argument
-
processReturn
public java.lang.Object processReturn(java.lang.Object oid, OpenJPAStateManager sm)
Description copied from interface:FindCallbacks
Process operation return value.- Specified by:
processReturn
in interfaceFindCallbacks
- Returns:
- the object to return
-
getPrintParameters
public boolean getPrintParameters()
- Returns:
- The value of openjpa.ConnectionFactoryProperties.PrintParameters. Default is false.
-
assignObjectId
protected void assignObjectId(java.lang.Object cache, java.lang.Object id, StateManagerImpl sm)
Assign the object id to the cache. Exception will be thrown if the id already exists in the cache.
-
checkForDuplicateId
protected void checkForDuplicateId(java.lang.Object id, java.lang.Object obj, ClassMetaData meta)
This method makes sure we don't already have the instance cached
-
getCachePreparedQuery
public boolean getCachePreparedQuery()
Description copied from interface:Broker
Affirms if this receiver is caching prepared queries.- Specified by:
getCachePreparedQuery
in interfaceBroker
-
setCachePreparedQuery
public void setCachePreparedQuery(boolean flag)
Description copied from interface:Broker
Sets whether this receiver will cache prepared queries during its lifetime. The cache configured at BrokerFactory level is not affected by setting it inactive for this receiver.- Specified by:
setCachePreparedQuery
in interfaceBroker
-
getCacheFinderQuery
public boolean getCacheFinderQuery()
-
setCacheFinderQuery
public void setCacheFinderQuery(boolean flag)
-
isFromWriteBehindCallback
public boolean isFromWriteBehindCallback()
-
getConnectionFactoryName
public java.lang.String getConnectionFactoryName()
Return the 'JTA' connectionFactoryName- Specified by:
getConnectionFactoryName
in interfaceStoreContext
-
setConnectionFactoryName
public void setConnectionFactoryName(java.lang.String connectionFactoryName)
Set the 'JTA' ConnectionFactoryName. Input will be trimmed to null before being stored.- Specified by:
setConnectionFactoryName
in interfaceStoreContext
-
getConnectionFactory2Name
public java.lang.String getConnectionFactory2Name()
Return the 'NonJTA' ConnectionFactoryName.- Specified by:
getConnectionFactory2Name
in interfaceStoreContext
-
setConnectionFactory2Name
public void setConnectionFactory2Name(java.lang.String connectionFactory2Name)
Set the 'NonJTA' ConnectionFactoryName. Input will be trimmed to null before being stored.- Specified by:
setConnectionFactory2Name
in interfaceStoreContext
-
getConnectionFactory
public java.lang.Object getConnectionFactory()
Return the 'JTA' ConnectionFactory, looking it up from JNDI if needed.- Specified by:
getConnectionFactory
in interfaceStoreContext
- Returns:
- the JTA connection factory or null if connectionFactoryName is blank.
-
getConnectionFactory2
public java.lang.Object getConnectionFactory2()
Return the 'NonJTA' ConnectionFactory, looking it up from JNDI if needed.- Specified by:
getConnectionFactory2
in interfaceStoreContext
- Returns:
- the NonJTA connection factory or null if connectionFactoryName is blank.
-
isCached
public boolean isCached(java.util.List<java.lang.Object> oids)
Description copied from interface:StoreContext
Indicate whether the oid can be found in the StoreContext's L1 cache or in the StoreManager cache.- Specified by:
isCached
in interfaceStoreContext
- Parameters:
oids
- List of ObjectIds for PersistenceCapables which may be found in memory.- Returns:
- true if the oid is available in memory (cached) otherwise false.
-
getAllowReferenceToSiblingContext
public boolean getAllowReferenceToSiblingContext()
Description copied from interface:StoreContext
Affirms if this context will allow its managed instances to refer instances that are managed by other contexts.- Specified by:
getAllowReferenceToSiblingContext
in interfaceStoreContext
- Returns:
- false by default.
-
setAllowReferenceToSiblingContext
public void setAllowReferenceToSiblingContext(boolean allow)
Description copied from interface:StoreContext
Affirms if this context will allow its managed instances to refer instances that are managed by other contexts. Note: Some specification (such as JPA) does not warranty predictable behavior when strict group-like property of a persistent context (where managed instances can only refer to instances managed by the same context). Please be aware of consequences when the flag is set to true.- Specified by:
setAllowReferenceToSiblingContext
in interfaceStoreContext
-
isFlushing
protected boolean isFlushing()
-
getPostLoadOnMerge
public boolean getPostLoadOnMerge()
Description copied from interface:StoreContext
Force sending a @PostLoad lifecycle event while merging.- Specified by:
getPostLoadOnMerge
in interfaceStoreContext
- Returns:
false
by default
-
setPostLoadOnMerge
public void setPostLoadOnMerge(boolean allow)
Description copied from interface:StoreContext
Set totrue
if the merge operation should trigger a @PostLoad lifecycle event.- Specified by:
setPostLoadOnMerge
in interfaceStoreContext
- Parameters:
allow
- PostLoad lifecycle events to be triggered on a merge operation
-
-