Package org.apache.openjpa.kernel
Class BrokerImpl
java.lang.Object
org.apache.openjpa.kernel.BrokerImpl
- All Implemented Interfaces:
jakarta.transaction.Synchronization,Serializable,Cloneable,CallbackModes,AutoClear,AutoDetach,Broker,ConnectionRetainModes,DetachState,FindCallbacks,LockLevels,RestoreState,StoreContext,Closeable
- Direct Known Subclasses:
FinalizingBrokerImpl
Concrete
Broker. The broker handles object-level behavior,
but leaves all interaction with the data store to a StoreManager
that must be supplied at initialization.- Author:
- Abe White
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUnique id for state managers of new datastore instances without assigned object ids. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intFlush in preparation of commit.protected static final intIncremental flush.protected static final intRun persistence-by-reachability and other flush-time operations without accessing the database.protected static final intFlush to check consistency of cache, then immediately rollback changes.Fields inherited from interface org.apache.openjpa.kernel.AutoClear
CLEAR_ALL, CLEAR_DATASTOREFields inherited from interface org.apache.openjpa.kernel.AutoDetach
DETACH_CLOSE, DETACH_COMMIT, DETACH_NONE, DETACH_NONTXREAD, DETACH_ROLLBACK, names, valuesFields inherited from interface org.apache.openjpa.event.CallbackModes
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACKFields inherited from interface org.apache.openjpa.kernel.ConnectionRetainModes
CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANSFields inherited from interface org.apache.openjpa.kernel.DetachState
DETACH_ALL, DETACH_FETCH_GROUPS, DETACH_FGS, DETACH_LOADEDFields inherited from interface org.apache.openjpa.kernel.LockLevels
LOCK_NONE, LOCK_READ, LOCK_WRITEFields inherited from interface org.apache.openjpa.kernel.RestoreState
RESTORE_ALL, RESTORE_IMMUTABLE, RESTORE_NONEFields inherited from interface org.apache.openjpa.kernel.StoreContext
EXCLUDE_ALL, OID_ALLOW_NEW, OID_COPY, OID_NODELETED, OID_NOVALIDATE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLifecycleListener(Object listener, Class[] classes) Register a listener for lifecycle-related events on the specified classes.voidRegister a listener for transaction-related events.voidafterCompletion(int status) voidThrow an exception if there is no active transaction.voidThrow an exception if there is no transaction active and nontransactional reading is not enabled.voidThrow an exception if the context is closed.protected PersistenceCapableReturn the given instance as aPersistenceCapable.voidThrow an exception if a write operation is not permitted (there is no active transaction and nontransactional writing is not enabled).protected voidassignObjectId(Object cache, Object id, StateManagerImpl sm) Assign the object id to the cache.attach(Object obj, boolean copyNew, OpCallbacks call) Import the specified detached object into the broker.Object[]attachAll(Collection objs, boolean copyNew, OpCallbacks call) Import the specified objects into the broker.voidvoidbegin()Begin a transaction.booleanbeginOperation(boolean syncTrans) Begin a logical operation.voidBegin a data store transaction.booleanCancel all pending data store statements.protected voidcheckForDuplicateId(Object id, Object obj, ClassMetaData meta) This method makes sure we don't already have the instance cachedprotected voidclearStatusFlag(int flag) Clears the given flag from the status.clone()voidclose()Close the broker.voidcommit()Commit the current transaction.voidIssue a commit and then start a new transaction.voiddelete(Object obj, OpCallbacks call) Delete the given object.voiddeleteAll(Collection objs, OpCallbacks call) Delete the given objects.detach(Object obj, OpCallbacks call) Detach the specified object from the broker.Object[]detachAll(Collection objs, OpCallbacks call) Detach the specified objects from the broker.voiddetachAll(OpCallbacks call) Detach all objects in place.voiddetachAll(OpCallbacks call, boolean flush) Detach all objects in place, with the option of performing a flush before doing the detachment.voidMark the given class as dirty within the current transaction.embed(Object obj, Object id, OpenJPAStateManager owner, ValueMetaData ownerMeta) Make the given instance embedded.booleanMark the operation over.protected voidendTransaction(int status) End the current transaction, making appropriate state transitions.voidevict(Object obj, OpCallbacks call) Evict the given object.voidevictAll(Collection objs, OpCallbacks call) Evict the given objects.voidevictAll(Extent extent, OpCallbacks call) Evict all persistent-clean and persistent-nontransactional instances in the givenExtent.voidevictAll(OpCallbacks call) Evict all clean objects.extentIterator(Class type, boolean subclasses, FetchConfiguration fetch, boolean ignoreChanges) Return an iterator over all instances of the given type.find(Object oid, boolean validate, FindCallbacks call) Find the persistence object with the given oid.find(Object oid, FetchConfiguration fetch, BitSet exclude, Object edata, int flags) Return the object with the given oid.protected Objectfind(Object oid, FetchConfiguration fetch, BitSet exclude, Object edata, int flags, FindCallbacks call) Internal finder.Object[]findAll(Collection oids, boolean validate, FindCallbacks call) Return the objects with the given oids.Object[]findAll(Collection oids, FetchConfiguration fetch, BitSet exclude, Object edata, int flags) Return the objects with the given oids.protected Object[]findAll(Collection oids, FetchConfiguration fetch, BitSet exclude, Object edata, int flags, FindCallbacks call) Internal finder.findCached(Object oid, FindCallbacks call) Return the instance for the given oid/object , or null if not found in the L1 cache.voidflush()Flush all transactional instances to the data store.protected voidflush(int reason) Flush the transactional state to the data store.protected voidfree()Free the resources used by this persistence manager.booleanAffirms if this context will allow its managed instances to refer instances that are managed by other contexts.intWhether objects clear when entering transactions.intBit flags marked inAutoDetachwhich indicate when persistent managed objects should be automatically detached in-place.Return the broker for this context, if possible.Return the factory that produced this broker.booleanbooleanAffirms if this receiver is caching prepared queries.Return the current thread's class loader at the time this context was obtained.Return the configuration associated with this context.Return the connection in use by the context, or a new connection if none.Return the 'JTA' ConnectionFactory, looking it up from JNDI if needed.Return the 'NonJTA' ConnectionFactory, looking it up from JNDI if needed.Return the 'NonJTA' ConnectionFactoryName.Return the 'JTA' connectionFactoryNameReturn the connection password.intReturn the connection retain mode for this broker.Return the connection user name.Return the set of classes that have been deleted in the current transaction.intDetach mode constant to determine which fields are part of the detached graph.Return a list of current dirty instances.protected CollectionReturn a copy of all dirty state managers.booleanWhether to also evict an object from the store cache when it is evicted through this broker.Return the (mutable) fetch configuration for loading objects from this context.Returns aSeqfor the datastore identity values of the specified persistent class, or null if the class' identity cannot be represented as a sequence.booleanWhether to take into account changes in the transaction when executing a query or iterating an extent.Return the inverse manager in use.Give state managers access to the lifecycle event manager.intThe callback mode for handling exceptions from lifecycle event listeners.intReturn the lock level of the specified object.Return the lock manager in use.Return a list of all managed instances.Return the managed runtime in use.protected CollectionReturn a copy of all managed state managers.booleanWhether the broker or its managed instances are used in a multithreaded environment.booleanWhether to allow nontransactional access to persistent state.booleanWhether to allow nontransactional changes to persistent state.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.Gets the unmodifiable set of instances being operated.booleanWhether to use optimistic transactional semantics.booleanWhether to maintain the order in which objects are dirtied forStoreContext.getDirtyObjects().Return a list of instances which will become transactional upon the next transaction.protected CollectionReturn a copy of all state managers which will become transactional upon the next transaction.Return the set of classes that have been made persistent in the current transaction.booleanWhether objects accessed during this transaction will be added to the store cache.booleanForce sending a @PostLoad lifecycle event while merging.booleanGet current configuration property values used by this instance.intWhether to restore an object's original state on rollback.booleanWhether objects retain their persistent state on transaction commit.Returns the Throwable that caused the transaction to be marked for rollback.booleanReturn whether the current transaction has been marked for rollback.getStateManager(Object obj) Return the state manager for the given instance.protected StateManagerImplgetStateManagerImpl(Object obj, boolean assertThisContext) Return the state manager for the given instance, or null.protected StateManagerImplgetStateManagerImplById(Object oid, boolean allowNew) Return the state manager for the given oid.Return the store manager in use.Gets the property names that can be used to corresponding setter methods of this receiver to set its value.booleanReturn whether this Broker will generate verbose optimistic lock exceptions when batching operations.jakarta.transaction.SynchronizationbooleanWhether to check for a global transaction upon every managed, non-transactional operation.Return a list of current transaction instances.protected Collection<StateManagerImpl>Return a copy of all transactional state managers.intThe callback mode for handling exceptions from transaction event listeners.Gets an umodifiable collection of currently registered lsteners.Return the set of classes for objects that have been modified in the current transaction.getUserObject(Object key) Get the value for the specified key from the map of user objects.Returns aSeqfor the generated values of the specified field, or null if the field is not generated.getVersion(Object obj) Returns the current version indicator foro.booleanWhether the broker has a dedicated connection based on the configured connection retain mode and transaction status.voidinitialize(AbstractBrokerFactory factory, DelegatingStoreManager sm, boolean managed, int connMode, boolean fromDeserialization) Initialize the persistence manager.voidinitialize(AbstractBrokerFactory factory, DelegatingStoreManager sm, boolean managed, int connMode, boolean fromDeserialization, boolean fromWriteBehindCallback) protected StateManagerImplinitialize(StateManagerImpl sm, boolean load, FetchConfiguration fetch, Object edata) Initialize a newly-constructed state manager.booleanisActive()Whether a logical transaction is active.booleanIndicate whether the oid can be found in the StoreContext's L1 cache or in the StoreManager cache.booleanisClosed()Whether the broker is closed.booleanWhetherBroker.close()has been invoked, though the broker might remain open until the current managed transaction completes.booleanReturn whether the given object is deleted.booleanisDetached(Object obj) Returnstrueifobjis a detached object (one that can be reattached to aBrokervia a call toBroker.attach(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)); otherwise returnsfalse.booleanisDetached(Object obj, boolean find) This method makes a best effort to determine if the provided object is detached.booleanWhether to treat relations to detached instances during persist operations as new or as pseudo-hollow instances.booleanReturn whether the given object is dirty.protected booleanbooleanbooleanbooleanWhether this context is using managed transactions.booleanReturn whether the given object is a newly-created instance registered withbroker.booleanisPersistent(Object obj) Return whether the given object is persistent.booleanWhether a data store transaction is active.booleanWhether 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.booleanisTransactional(Object obj) Return whether the given object is transactional.voidlock()Synchronizes on an internal lock if theMultithreadedflag is set to true.voidlock(Object obj, int level, int timeout, OpCallbacks call) Ensure that the given instance is locked at the given lock level.voidlock(Object obj, OpCallbacks call) Ensure that the given instance is locked at the current lock level, as set in theFetchConfigurationfor the broker.voidlockAll(Collection objs, int level, int timeout, OpCallbacks call) Ensure that the given instances are locked at the given lock level.voidlockAll(Collection objs, OpCallbacks call) Ensure that the given instances are locked at the current lock level, as set in theFetchConfigurationfor the broker.Return an extent of the given class, optionally including subclasses.newInstance(Class cls) Create a new instance of typecls.protected Map<?,?> Create aMapto be used for the primary managed object cache.newObjectId(Class<?> cls, Object val) Create a new object id instance from the given value.Create a new query from the given data, with the given candidate class and language.Create a new query in the given language.protected QueryImplnewQueryImpl(String lang, StoreQuery sq) Create a new query.protected StateManagerImplnewStateManagerImpl(Object oid, ClassMetaData meta) Create a state manager for the given oid and metadata.voidnontransactional(Object obj, OpCallbacks call) Make the given object non-transactional.voidnontransactionalAll(Collection objs, OpCallbacks call) Make the given objects nontransactional.voidpersist(Object obj, boolean explicit, OpCallbacks call) Persist the given object.persist(Object obj, Object id, boolean explicit, OpCallbacks call) Persist the given object.persist(Object obj, Object id, boolean explicit, OpCallbacks call, boolean fireEvent) Persist the given object.persist(Object obj, Object id, OpCallbacks call) Make the given instance persistent.voidpersist(Object obj, OpCallbacks call) Persist the given object.voidpersistAll(Collection objs, boolean explicit, OpCallbacks call) Persist the given objects.voidpersistAll(Collection objs, OpCallbacks call) Persist the given objects.voidPops the fetch configuration from the top of the stack, making the next one down the active one.voidpreFlush()Run pre-flush actions on transactional objects, including persistence-by-reachability, inverse relationship management, deletion of dependent instances, and instance callbacks.processArgument(Object oid) Process find argument.processReturn(Object oid, OpenJPAStateManager sm) Process operation return value.Pushes a new fetch configuration that inherits from the current fetch configuration onto a stack, and makes the new configuration the active one.Pushes the fetch configuration argument onto a stack, and makes the new configuration the active one.putUserObject(Object key, Object val) Put the specified key-value pair into the map of user objects.voidrefresh(Object obj, OpCallbacks call) Refresh the state of the given object.voidrefreshAll(Collection objs, OpCallbacks call) Refresh the state of the given objects.protected voidrefreshInternal(Object obj, OpCallbacks call) Optimization for single-object refresh.protected voidrefreshInternal(Collection objs, OpCallbacks call) This method is called with the full set of objects reachable via cascade-refresh relations from the user-given instances.voidrelease(Object obj, OpCallbacks call) Release the given object from management.voidreleaseAll(Collection objs, OpCallbacks call) Release the given objects from management.voidRelease the last set savepoint and any resources associated with it.voidreleaseSavepoint(String savepoint) Release the savepoint and any resources associated with it.voidremoveLifecycleListener(Object listener) Remove a listener for lifecycle-related events.voidRemove a listener for transaction-related events.voidretrieve(Object obj, boolean dfgOnly, OpCallbacks call) Immediately load the given object's persistent fields.voidretrieveAll(Collection objs, boolean dfgOnly, OpCallbacks call) Retrieve the given objects' persistent state.voidrollback()Rollback the current transaction.voidIssue a rollback and then start a new transaction.voidRollback the current transaction to the last savepoint.voidrollbackToSavepoint(String savepoint) Rollback the current transaction to the given savepoint name.voidsetAllowReferenceToSiblingContext(boolean allow) Affirms if this context will allow its managed instances to refer instances that are managed by other contexts.voidsetAuthentication(String user, String pass) Set the persistence manager's authentication.voidsetAutoClear(int val) Whether objects clear when entering transactions.voidsetAutoDetach(int detachFlags) Sets automatic detachment option.voidsetAutoDetach(int detachFlag, boolean on) Bit flags marked inAutoDetachwhich indicate when persistent managed objects should be automatically detached in-place.voidsetCacheFinderQuery(boolean flag) voidsetCachePreparedQuery(boolean flag) Sets whether this receiver will cache prepared queries during its lifetime.voidsetConnectionFactory2Name(String connectionFactory2Name) Set the 'NonJTA' ConnectionFactoryName.voidsetConnectionFactoryName(String connectionFactoryName) Set the 'JTA' ConnectionFactoryName.voidsetDetachedNew(boolean isNew) Whether to treat relations to detached instances as new.voidsetDetachState(int mode) Detach mode constant to determine which fields are part of the detached graph.voidsetEvictFromDataCache(boolean evict) Whether to also evict an object from the store cache when it is evicted through this broker.voidsetIgnoreChanges(boolean val) Whether to take into account changes in the transaction when executing a query or iterating an extent.voidSet the broker's behavior for implicit actions such as flushing, automatic detachment, and exceptions thrown by managed instances outside a broker operation.voidsetLifecycleListenerCallbackMode(int mode) The callback mode for handling exceptions from lifecycle event listeners.voidsetMultithreaded(boolean multithreaded) Whether the broker or its managed instances are used in a multithreaded environment.voidsetNontransactionalRead(boolean val) Whether to allow nontransactional access to persistent state.voidsetNontransactionalWrite(boolean val) Whether to allow nontransactional changes to persistent state.voidsetOptimistic(boolean val) Whether to use optimistic transactional semantics.voidsetOrderDirtyObjects(boolean order) Whether to maintain the order in which objects are dirtied forStoreContext.getDirtyObjects().voidsetPopulateDataCache(boolean cache) Whether to populate the store cache with objects used by this transaction.voidsetPostLoadOnMerge(boolean allow) Set totrueif the merge operation should trigger a @PostLoad lifecycle event.voidsetRestoreState(int val) Whether to restore an object's original state on rollback.voidsetRetainState(boolean val) Whether objects retain their persistent state on transaction commit.voidMark the current transaction for rollback.voidsetRollbackOnly(Throwable cause) Mark the current transaction for rollback with the specified cause of the rollback.voidsetSavepoint(String name) Set a transactional savepoint where operations after this savepoint will be rolled back.protected voidsetStateManager(Object id, StateManagerImpl sm, int status) Set the cached StateManager for the instance that had the given oid.protected voidsetStatusFlag(int flag) Sets the given flag to the status.voidsetSuppressBatchOLELogging(boolean b) Set whether this Broker will generate verbose optimistic lock exceptions when batching operations.voidsetSynchronization(jakarta.transaction.Synchronization sync) voidsetSyncWithManagedTransactions(boolean sync) Whether to check for a global transaction upon every managed, non-transactional operation.voidsetTrackChangesByType(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.voidsetTransactionListenerCallbackMode(int mode) The callback mode for handling exceptions from transaction event listeners.booleanAttempt to synchronize with a current managed transaction, returning true if successful, false if no managed transaction is active.voidtransactional(Object obj, boolean updateVersion, OpCallbacks call) Make the given instances transactional.voidtransactionalAll(Collection objs, boolean updateVersion, OpCallbacks call) Make the given instances transactional.voidunlock()Releases the internal lock.voidValidate the changes made in this transaction, reporting any optimistic violations, constraint violations, etc.
-
Field Details
-
FLUSH_INC
protected static final int FLUSH_INCIncremental flush.- See Also:
-
FLUSH_COMMIT
protected static final int FLUSH_COMMITFlush in preparation of commit.- See Also:
-
FLUSH_ROLLBACK
protected static final int FLUSH_ROLLBACKFlush to check consistency of cache, then immediately rollback changes.- See Also:
-
FLUSH_LOGICAL
protected static final int FLUSH_LOGICALRun persistence-by-reachability and other flush-time operations without accessing the database.- See Also:
-
-
Constructor Details
-
BrokerImpl
public BrokerImpl()
-
-
Method Details
-
setAuthentication
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
Gets the unmodifiable set of instances being operated. -
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
newManagedObjectCache
Create aMapto be used for the primary managed object cache. Maps oids to state managers. By default, this creates aReferenceMapwith soft values. -
getBroker
Description copied from interface:StoreContextReturn 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:
getBrokerin interfaceStoreContext
-
setImplicitBehavior
Description copied from interface:BrokerSet 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:
setImplicitBehaviorin interfaceBroker
-
getBrokerFactory
Description copied from interface:BrokerReturn the factory that produced this broker.- Specified by:
getBrokerFactoryin interfaceBroker
-
getConfiguration
Description copied from interface:StoreContextReturn the configuration associated with this context.- Specified by:
getConfigurationin interfaceStoreContext
-
getFetchConfiguration
Description copied from interface:StoreContextReturn the (mutable) fetch configuration for loading objects from this context.- Specified by:
getFetchConfigurationin interfaceStoreContext
-
pushFetchConfiguration
Description copied from interface:StoreContextPushes a new fetch configuration that inherits from the current fetch configuration onto a stack, and makes the new configuration the active one.- Specified by:
pushFetchConfigurationin interfaceStoreContext- Returns:
- the new fetch configuration
-
pushFetchConfiguration
Description copied from interface:StoreContextPushes the fetch configuration argument onto a stack, and makes the new configuration the active one.- Specified by:
pushFetchConfigurationin interfaceStoreContext- Returns:
- the new fetch configuration
-
popFetchConfiguration
public void popFetchConfiguration()Description copied from interface:StoreContextPops 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:
popFetchConfigurationin interfaceStoreContext
-
getConnectionRetainMode
public int getConnectionRetainMode()Description copied from interface:BrokerReturn the connection retain mode for this broker.- Specified by:
getConnectionRetainModein interfaceBroker
-
isManaged
public boolean isManaged()Description copied from interface:StoreContextWhether this context is using managed transactions.- Specified by:
isManagedin interfaceStoreContext
-
getManagedRuntime
Description copied from interface:BrokerReturn the managed runtime in use.- Specified by:
getManagedRuntimein interfaceBroker
-
getClassLoader
Description copied from interface:StoreContextReturn the current thread's class loader at the time this context was obtained.- Specified by:
getClassLoaderin interfaceStoreContext
-
getStoreManager
Description copied from interface:StoreContextReturn the store manager in use. This will be a wrapper around the native store manager, which you can retrieve viaDelegatingStoreManager.getInnermostDelegate().- Specified by:
getStoreManagerin interfaceStoreContext
-
getLockManager
Description copied from interface:StoreContextReturn the lock manager in use.- Specified by:
getLockManagerin interfaceStoreContext
-
getInverseManager
Description copied from interface:BrokerReturn the inverse manager in use.- Specified by:
getInverseManagerin interfaceBroker
-
getConnectionUserName
Description copied from interface:StoreContextReturn the connection user name.- Specified by:
getConnectionUserNamein interfaceStoreContext
-
getConnectionPassword
Description copied from interface:StoreContextReturn the connection password.- Specified by:
getConnectionPasswordin interfaceStoreContext
-
getMultithreaded
public boolean getMultithreaded()Description copied from interface:BrokerWhether the broker or its managed instances are used in a multithreaded environment.- Specified by:
getMultithreadedin interfaceBroker
-
setMultithreaded
public void setMultithreaded(boolean multithreaded) Description copied from interface:BrokerWhether the broker or its managed instances are used in a multithreaded environment.- Specified by:
setMultithreadedin interfaceBroker
-
getIgnoreChanges
public boolean getIgnoreChanges()Description copied from interface:BrokerWhether to take into account changes in the transaction when executing a query or iterating an extent.- Specified by:
getIgnoreChangesin interfaceBroker
-
setIgnoreChanges
public void setIgnoreChanges(boolean val) Description copied from interface:BrokerWhether to take into account changes in the transaction when executing a query or iterating an extent.- Specified by:
setIgnoreChangesin interfaceBroker
-
getNontransactionalRead
public boolean getNontransactionalRead()Description copied from interface:BrokerWhether to allow nontransactional access to persistent state.- Specified by:
getNontransactionalReadin interfaceBroker
-
setNontransactionalRead
public void setNontransactionalRead(boolean val) Description copied from interface:BrokerWhether to allow nontransactional access to persistent state.- Specified by:
setNontransactionalReadin interfaceBroker
-
getNontransactionalWrite
public boolean getNontransactionalWrite()Description copied from interface:BrokerWhether to allow nontransactional changes to persistent state.- Specified by:
getNontransactionalWritein interfaceBroker
-
setNontransactionalWrite
public void setNontransactionalWrite(boolean val) Description copied from interface:BrokerWhether to allow nontransactional changes to persistent state.- Specified by:
setNontransactionalWritein interfaceBroker
-
getOptimistic
public boolean getOptimistic()Description copied from interface:BrokerWhether to use optimistic transactional semantics.- Specified by:
getOptimisticin interfaceBroker
-
setOptimistic
public void setOptimistic(boolean val) Description copied from interface:BrokerWhether to use optimistic transactional semantics.- Specified by:
setOptimisticin interfaceBroker
-
getRestoreState
public int getRestoreState()Description copied from interface:BrokerWhether to restore an object's original state on rollback.- Specified by:
getRestoreStatein interfaceBroker
-
setRestoreState
public void setRestoreState(int val) Description copied from interface:BrokerWhether to restore an object's original state on rollback.- Specified by:
setRestoreStatein interfaceBroker
-
getRetainState
public boolean getRetainState()Description copied from interface:BrokerWhether objects retain their persistent state on transaction commit.- Specified by:
getRetainStatein interfaceBroker
-
setRetainState
public void setRetainState(boolean val) Description copied from interface:BrokerWhether objects retain their persistent state on transaction commit.- Specified by:
setRetainStatein interfaceBroker
-
getAutoClear
public int getAutoClear()Description copied from interface:BrokerWhether objects clear when entering transactions.- Specified by:
getAutoClearin interfaceBroker
-
setAutoClear
public void setAutoClear(int val) Description copied from interface:BrokerWhether objects clear when entering transactions.- Specified by:
setAutoClearin interfaceBroker
-
getAutoDetach
public int getAutoDetach()Description copied from interface:BrokerBit flags marked inAutoDetachwhich indicate when persistent managed objects should be automatically detached in-place.- Specified by:
getAutoDetachin interfaceBroker
-
setAutoDetach
public void setAutoDetach(int detachFlags) Sets automatic detachment option.
If the given flag containsAutoDetach.DETACH_NONEoption, then no other option can be specified.- Specified by:
setAutoDetachin interfaceBroker
-
setAutoDetach
public void setAutoDetach(int detachFlag, boolean on) Description copied from interface:BrokerBit flags marked inAutoDetachwhich indicate when persistent managed objects should be automatically detached in-place.- Specified by:
setAutoDetachin interfaceBroker
-
getDetachState
public int getDetachState()Description copied from interface:StoreContextDetach mode constant to determine which fields are part of the detached graph. Defaults toDetachState.DETACH_LOADED.- Specified by:
getDetachStatein interfaceStoreContext
-
setDetachState
public void setDetachState(int mode) Description copied from interface:StoreContextDetach mode constant to determine which fields are part of the detached graph. Defaults toDetachState.DETACH_LOADED.- Specified by:
setDetachStatein interfaceStoreContext
-
isDetachedNew
public boolean isDetachedNew()Description copied from interface:BrokerWhether to treat relations to detached instances during persist operations as new or as pseudo-hollow instances.- Specified by:
isDetachedNewin interfaceBroker
-
setDetachedNew
public void setDetachedNew(boolean isNew) Description copied from interface:BrokerWhether to treat relations to detached instances as new.- Specified by:
setDetachedNewin interfaceBroker
-
getSyncWithManagedTransactions
public boolean getSyncWithManagedTransactions()Description copied from interface:BrokerWhether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.- Specified by:
getSyncWithManagedTransactionsin interfaceBroker
-
setSyncWithManagedTransactions
public void setSyncWithManagedTransactions(boolean sync) Description copied from interface:BrokerWhether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.- Specified by:
setSyncWithManagedTransactionsin interfaceBroker
-
getEvictFromDataCache
public boolean getEvictFromDataCache()Description copied from interface:BrokerWhether to also evict an object from the store cache when it is evicted through this broker.- Specified by:
getEvictFromDataCachein interfaceBroker
-
setEvictFromDataCache
public void setEvictFromDataCache(boolean evict) Description copied from interface:BrokerWhether to also evict an object from the store cache when it is evicted through this broker.- Specified by:
setEvictFromDataCachein interfaceBroker
-
getPopulateDataCache
public boolean getPopulateDataCache()Description copied from interface:StoreContextWhether objects accessed during this transaction will be added to the store cache. Defaults to true.- Specified by:
getPopulateDataCachein interfaceStoreContext
-
setPopulateDataCache
public void setPopulateDataCache(boolean cache) Description copied from interface:StoreContextWhether to populate the store cache with objects used by this transaction. Defaults to true.- Specified by:
setPopulateDataCachein interfaceStoreContext
-
isTrackChangesByType
public boolean isTrackChangesByType()Description copied from interface:StoreContextWhether 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:
isTrackChangesByTypein interfaceStoreContext
-
setTrackChangesByType
public void setTrackChangesByType(boolean largeTransaction) Description copied from interface:StoreContextIf 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 forRemoteCommitEvents. Defaults to false.- Specified by:
setTrackChangesByTypein interfaceStoreContext
-
getUserObject
Description copied from interface:BrokerGet the value for the specified key from the map of user objects.- Specified by:
getUserObjectin interfaceBroker
-
putUserObject
Description copied from interface:BrokerPut the specified key-value pair into the map of user objects. Use a value of null to remove the key.- Specified by:
putUserObjectin interfaceBroker
-
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:
getPropertiesin interfaceBroker- Returns:
- the changed properties
-
getSupportedProperties
Gets the property names that can be used to corresponding setter methods of this receiver to set its value.- Specified by:
getSupportedPropertiesin interfaceBroker
-
addLifecycleListener
Description copied from interface:BrokerRegister 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:
addLifecycleListenerin interfaceBroker
-
removeLifecycleListener
Description copied from interface:BrokerRemove a listener for lifecycle-related events.- Specified by:
removeLifecycleListenerin interfaceBroker
-
getLifecycleListenerCallbackMode
public int getLifecycleListenerCallbackMode()Description copied from interface:BrokerThe callback mode for handling exceptions from lifecycle event listeners.- Specified by:
getLifecycleListenerCallbackModein interfaceBroker
-
setLifecycleListenerCallbackMode
public void setLifecycleListenerCallbackMode(int mode) Description copied from interface:BrokerThe callback mode for handling exceptions from lifecycle event listeners.- Specified by:
setLifecycleListenerCallbackModein interfaceBroker
-
getLifecycleEventManager
Give state managers access to the lifecycle event manager.- Specified by:
getLifecycleEventManagerin interfaceBroker
-
addTransactionListener
Description copied from interface:BrokerRegister a listener for transaction-related events.- Specified by:
addTransactionListenerin interfaceBroker
-
removeTransactionListener
Description copied from interface:BrokerRemove a listener for transaction-related events.- Specified by:
removeTransactionListenerin interfaceBroker
-
getTransactionListeners
Description copied from interface:BrokerGets an umodifiable collection of currently registered lsteners.- Specified by:
getTransactionListenersin interfaceBroker
-
getTransactionListenerCallbackMode
public int getTransactionListenerCallbackMode()Description copied from interface:BrokerThe callback mode for handling exceptions from transaction event listeners.- Specified by:
getTransactionListenerCallbackModein interfaceBroker
-
setTransactionListenerCallbackMode
public void setTransactionListenerCallbackMode(int mode) Description copied from interface:BrokerThe callback mode for handling exceptions from transaction event listeners.- Specified by:
setTransactionListenerCallbackModein 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
Description copied from interface:StoreContextFind the persistence object with the given oid. Ifvalidateis true, the broker will check the store for the object, and return null if it does not exist. Ifvalidateis false, this method never returns null. The broker will either return its cached instance, attempt to create a hollow instance, or throw anObjectNotFoundExceptionif unable to return a hollow instance.- Specified by:
findin interfaceStoreContextvalidate- if true, validate that the instance exists in the store and load fetch group fields, otherwise return any cached or hollow instance
-
find
Description copied from interface:StoreContextReturn 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 theexcludemask. 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_XXXflags.- Specified by:
findin interfaceStoreContext
-
find
protected Object find(Object oid, FetchConfiguration fetch, BitSet exclude, Object edata, int flags, FindCallbacks call) Internal finder. -
initialize
protected StateManagerImpl initialize(StateManagerImpl sm, boolean load, FetchConfiguration fetch, Object edata) Initialize a newly-constructed state manager. -
findAll
Description copied from interface:StoreContextReturn the objects with the given oids.- Specified by:
findAllin 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:
-
findAll
public Object[] findAll(Collection oids, FetchConfiguration fetch, BitSet exclude, Object edata, int flags) Description copied from interface:StoreContextReturn the objects with the given oids.- Specified by:
findAllin interfaceStoreContext- See Also:
-
findAll
protected Object[] findAll(Collection oids, FetchConfiguration fetch, BitSet exclude, Object edata, int flags, FindCallbacks call) Internal finder. -
isLoading
-
findCached
Description copied from interface:StoreContextReturn the instance for the given oid/object , or null if not found in the L1 cache.- Specified by:
findCachedin interfaceStoreContext- Parameters:
oid- the object's id- Returns:
- the cached object, or null if not cached
-
getObjectIdType
Description copied from interface:StoreContextReturn the application or datastore identity class the given persistent class uses for object ids.- Specified by:
getObjectIdTypein interfaceStoreContext
-
newObjectId
Description copied from interface:StoreContextCreate a new object id instance from the given value.- Specified by:
newObjectIdin interfaceStoreContext- Parameters:
cls- the persistent class that uses this identity valueval- an object id instance, stringified object id, or primary key value
-
newStateManagerImpl
Create a state manager for the given oid and metadata. -
begin
public void begin()Description copied from interface:BrokerBegin a transaction. -
beginStore
public void beginStore()Description copied from interface:StoreContextBegin a data store transaction.- Specified by:
beginStorein interfaceStoreContext
-
commit
public void commit()Description copied from interface:BrokerCommit the current transaction. -
rollback
public void rollback()Description copied from interface:BrokerRollback the current transaction. -
syncWithManagedTransaction
public boolean syncWithManagedTransaction()Description copied from interface:BrokerAttempt to synchronize with a current managed transaction, returning true if successful, false if no managed transaction is active.- Specified by:
syncWithManagedTransactionin interfaceBroker
-
commitAndResume
public void commitAndResume()Description copied from interface:BrokerIssue 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:
commitAndResumein interfaceBroker- See Also:
-
rollbackAndResume
public void rollbackAndResume()Description copied from interface:BrokerIssue 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:
rollbackAndResumein interfaceBroker- See Also:
-
getRollbackOnly
public boolean getRollbackOnly()Description copied from interface:BrokerReturn whether the current transaction has been marked for rollback.- Specified by:
getRollbackOnlyin interfaceBroker
-
getRollbackCause
Description copied from interface:BrokerReturns the Throwable that caused the transaction to be marked for rollback.- Specified by:
getRollbackCausein interfaceBroker- Returns:
- the Throwable, or null if none was given
-
setRollbackOnly
public void setRollbackOnly()Description copied from interface:BrokerMark the current transaction for rollback.- Specified by:
setRollbackOnlyin interfaceBroker
-
setRollbackOnly
Description copied from interface:BrokerMark the current transaction for rollback with the specified cause of the rollback.- Specified by:
setRollbackOnlyin interfaceBroker
-
setSavepoint
Description copied from interface:BrokerSet a transactional savepoint where operations after this savepoint will be rolled back.- Specified by:
setSavepointin interfaceBroker
-
releaseSavepoint
public void releaseSavepoint()Description copied from interface:BrokerRelease the last set savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.- Specified by:
releaseSavepointin interfaceBroker
-
releaseSavepoint
Description copied from interface:BrokerRelease the savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.- Specified by:
releaseSavepointin interfaceBroker
-
rollbackToSavepoint
public void rollbackToSavepoint()Description copied from interface:BrokerRollback the current transaction to the last savepoint. Savepoints set after this one will become invalid.- Specified by:
rollbackToSavepointin interfaceBroker
-
rollbackToSavepoint
Description copied from interface:BrokerRollback the current transaction to the given savepoint name. Savepoints set after this one will become invalid.- Specified by:
rollbackToSavepointin 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:BrokerFlush 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:BrokerRun 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:BrokerValidate 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:
validateChangesin interfaceBroker
-
isActive
public boolean isActive()Description copied from interface:StoreContextWhether a logical transaction is active.- Specified by:
isActivein interfaceStoreContext
-
isStoreActive
public boolean isStoreActive()Description copied from interface:StoreContextWhether a data store transaction is active.- Specified by:
isStoreActivein interfaceStoreContext
-
beginOperation
public boolean beginOperation(boolean syncTrans) Description copied from interface:BrokerBegin 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:
beginOperationin 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:
endOperationin 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:
beforeCompletionin interfacejakarta.transaction.Synchronization
-
afterCompletion
public void afterCompletion(int status) - Specified by:
afterCompletionin 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
Description copied from interface:BrokerPersist the given object. -
persist
Description copied from interface:BrokerMake the given instance persistent. Unlike other persist operations, this method does not immediately cascade to fields markedValueMetaData.CASCADE_IMMEDIATE. -
persistAll
Description copied from interface:BrokerPersist the given objects.- Specified by:
persistAllin interfaceBroker
-
persistAll
Persist the given objects. Indicate whether this was an explicit persist (PNEW) or a provisonal persist (PNEWPROVISIONAL). -
persist
Persist the given object. Indicate whether this was an explicit persist (PNEW) or a provisonal persist (PNEWPROVISIONAL) -
persist
Persist the given object. Indicate whether this was an explicit persist (PNEW) or a provisonal persist (PNEWPROVISIONAL). SeeBrokerfor details on this method. -
persist
public OpenJPAStateManager persist(Object obj, 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). SeeBrokerfor details on this method. -
deleteAll
Description copied from interface:BrokerDelete the given objects. -
delete
Description copied from interface:BrokerDelete the given object. -
releaseAll
Description copied from interface:BrokerRelease the given objects from management. This operation is not recursive.- Specified by:
releaseAllin interfaceBroker
-
release
Description copied from interface:BrokerRelease the given object from management. This operation is not recursive. -
embed
public OpenJPAStateManager embed(Object obj, Object id, OpenJPAStateManager owner, ValueMetaData ownerMeta) Description copied from interface:StoreContextMake the given instance embedded.- Specified by:
embedin 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
Description copied from interface:BrokerRefresh the state of the given objects.- Specified by:
refreshAllin interfaceBroker
-
refresh
Description copied from interface:BrokerRefresh the state of the given object. -
refreshInternal
This method is called with the full set of objects reachable via cascade-refresh relations from the user-given instances. -
refreshInternal
Optimization for single-object refresh. -
retrieveAll
Description copied from interface:StoreContextRetrieve the given objects' persistent state. Unmanaged targets are ignored.- Specified by:
retrieveAllin interfaceStoreContextdfgOnly- indicator as to whether to retrieve only fields- See Also:
-
retrieve
Description copied from interface:StoreContextImmediately 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:
retrievein interfaceStoreContextdfgOnly- indicator as to whether to retrieve only fields in the current fetch groups, or all fields- See Also:
-
evictAll
Description copied from interface:BrokerEvict all clean objects. -
evictAll
Description copied from interface:BrokerEvict the given objects. -
evictAll
Description copied from interface:BrokerEvict all persistent-clean and persistent-nontransactional instances in the givenExtent. -
evict
Description copied from interface:BrokerEvict the given object. -
detach
Description copied from interface:BrokerDetach the specified object from the broker. -
detachAll
Description copied from interface:BrokerDetach 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 currentFetchConfigurationwill 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
Description copied from interface:BrokerDetach all objects in place. A flush will be performed before detaching the entities. -
detachAll
Description copied from interface:BrokerDetach all objects in place, with the option of performing a flush before doing the detachment. -
attach
Description copied from interface:BrokerImport the specified detached object into the broker. -
attachAll
Description copied from interface:BrokerImport 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
Description copied from interface:StoreContextMake the given objects nontransactional.- Specified by:
nontransactionalAllin interfaceStoreContext
-
nontransactional
Description copied from interface:StoreContextMake the given object non-transactional.- Specified by:
nontransactionalin interfaceStoreContext
-
transactionalAll
Make the given instances transactional.- Specified by:
transactionalAllin interfaceStoreContext- Parameters:
objs- instances to make transactionalupdateVersion- if true, the instance's version will be incremented at the next flush
-
transactional
Make the given instances transactional.- Specified by:
transactionalin interfaceStoreContext- Parameters:
obj- instance to make transactionalupdateVersion- if true, the instance's version will be incremented at the next flush
-
newExtent
Description copied from interface:BrokerReturn an extent of the given class, optionally including subclasses. -
extentIterator
public Iterator extentIterator(Class type, boolean subclasses, FetchConfiguration fetch, boolean ignoreChanges) Description copied from interface:StoreContextReturn 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:
extentIteratorin interfaceStoreContext
-
newQuery
Description copied from interface:BrokerCreate a new query from the given data, with the given candidate class and language. -
newQuery
Description copied from interface:BrokerCreate a new query in the given language. -
newQueryImpl
Create a new query. -
getIdentitySequence
Description copied from interface:BrokerReturns aSeqfor the datastore identity values of the specified persistent class, or null if the class' identity cannot be represented as a sequence.- Specified by:
getIdentitySequencein interfaceBroker
-
getValueSequence
Description copied from interface:BrokerReturns aSeqfor the generated values of the specified field, or null if the field is not generated.- Specified by:
getValueSequencein interfaceBroker
-
lock
Description copied from interface:BrokerEnsure that the given instance is locked at the current lock level, as set in theFetchConfigurationfor the broker. -
lock
Description copied from interface:BrokerEnsure that the given instance is locked at the given lock level. -
lockAll
Description copied from interface:BrokerEnsure that the given instances are locked at the current lock level, as set in theFetchConfigurationfor the broker. -
lockAll
Description copied from interface:BrokerEnsure that the given instances are locked at the given lock level. -
cancelAll
public boolean cancelAll()Description copied from interface:BrokerCancel all pending data store statements. If statements are cancelled while a flush is in progress, the transaction rollback only flag will be set. -
getConnection
Description copied from interface:StoreContextReturn the connection in use by the context, or a new connection if none.- Specified by:
getConnectionin interfaceStoreContext
-
hasConnection
public boolean hasConnection()Description copied from interface:StoreContextWhether the broker has a dedicated connection based on the configured connection retain mode and transaction status.- Specified by:
hasConnectionin interfaceStoreContext
-
getManagedObjects
Description copied from interface:StoreContextReturn a list of all managed instances.- Specified by:
getManagedObjectsin interfaceStoreContext
-
getTransactionalObjects
Description copied from interface:StoreContextReturn a list of current transaction instances.- Specified by:
getTransactionalObjectsin interfaceStoreContext
-
getPendingTransactionalObjects
Description copied from interface:StoreContextReturn a list of instances which will become transactional upon the next transaction.- Specified by:
getPendingTransactionalObjectsin interfaceStoreContext
-
getDirtyObjects
Description copied from interface:StoreContextReturn a list of current dirty instances.- Specified by:
getDirtyObjectsin interfaceStoreContext
-
getOrderDirtyObjects
public boolean getOrderDirtyObjects()Description copied from interface:StoreContextWhether to maintain the order in which objects are dirtied forStoreContext.getDirtyObjects(). Default is the store manager's decision.- Specified by:
getOrderDirtyObjectsin interfaceStoreContext
-
setOrderDirtyObjects
public void setOrderDirtyObjects(boolean order) Description copied from interface:StoreContextWhether to maintain the order in which objects are dirtied forStoreContext.getDirtyObjects(). Default is the store manager's decision.- Specified by:
setOrderDirtyObjectsin interfaceStoreContext
-
getManagedStates
Return a copy of all managed state managers. -
getTransactionalStates
Return a copy of all transactional state managers. -
getDirtyStates
Return a copy of all dirty state managers. -
getPendingTransactionalStates
Return a copy of all state managers which will become transactional upon the next transaction. -
setStateManager
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
Description copied from interface:BrokerMark the given class as dirty within the current transaction. -
getPersistedTypes
Description copied from interface:StoreContextReturn the set of classes that have been made persistent in the current transaction.- Specified by:
getPersistedTypesin interfaceStoreContext
-
getUpdatedTypes
Description copied from interface:StoreContextReturn the set of classes for objects that have been modified in the current transaction.- Specified by:
getUpdatedTypesin interfaceStoreContext
-
getDeletedTypes
Description copied from interface:StoreContextReturn the set of classes that have been deleted in the current transaction.- Specified by:
getDeletedTypesin interfaceStoreContext
-
isClosed
public boolean isClosed()Description copied from interface:BrokerWhether the broker is closed. -
isCloseInvoked
public boolean isCloseInvoked()Description copied from interface:BrokerWhetherBroker.close()has been invoked, though the broker might remain open until the current managed transaction completes.- Specified by:
isCloseInvokedin interfaceBroker
-
close
public void close()Description copied from interface:BrokerClose the broker. -
free
protected void free()Free the resources used by this persistence manager. -
lock
public void lock()Description copied from interface:StoreContextSynchronizes on an internal lock if theMultithreadedflag is set to true. Make sure to callStoreContext.unlock()in a finally clause of the same method.- Specified by:
lockin interfaceStoreContext
-
unlock
public void unlock()Description copied from interface:StoreContextReleases the internal lock.- Specified by:
unlockin interfaceStoreContext
-
newInstance
Description copied from interface:BrokerCreate a new instance of typecls. Ifclsis 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, ifclsis a managed type, this will return an instance of the specified class.- Specified by:
newInstancein interfaceBroker
-
getObjectId
Description copied from interface:StoreContextReturn the oid of the given instance.- Specified by:
getObjectIdin interfaceStoreContext
-
getLockLevel
Description copied from interface:StoreContextReturn the lock level of the specified object.- Specified by:
getLockLevelin interfaceStoreContext
-
getVersion
Description copied from interface:StoreContextReturns the current version indicator foro.- Specified by:
getVersionin interfaceStoreContext
-
isDirty
Description copied from interface:StoreContextReturn whether the given object is dirty.- Specified by:
isDirtyin interfaceStoreContext
-
isTransactional
Description copied from interface:StoreContextReturn whether the given object is transactional.- Specified by:
isTransactionalin interfaceStoreContext
-
isPersistent
Description copied from interface:StoreContextReturn whether the given object is persistent.- Specified by:
isPersistentin interfaceStoreContext
-
isNew
Description copied from interface:StoreContextReturn whether the given object is a newly-created instance registered withbroker.- Specified by:
isNewin interfaceStoreContext
-
isDeleted
Description copied from interface:StoreContextReturn whether the given object is deleted.- Specified by:
isDeletedin interfaceStoreContext
-
isDetached
Description copied from interface:BrokerReturnstrueifobjis a detached object (one that can be reattached to aBrokervia a call toBroker.attach(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)); otherwise returnsfalse.- Specified by:
isDetachedin interfaceBroker
-
isDetached
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
Description copied from interface:StoreContextReturn the state manager for the given instance. Includes objects made persistent in the current transaction. Ifobjis not a managed type or is managed by another context, throw an exception.- Specified by:
getStateManagerin interfaceStoreContext
-
getStateManagerImpl
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
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
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:
assertOpenin interfaceBroker
-
assertActiveTransaction
public void assertActiveTransaction()Description copied from interface:BrokerThrow an exception if there is no active transaction.- Specified by:
assertActiveTransactionin interfaceBroker
-
assertNontransactionalRead
public void assertNontransactionalRead()Description copied from interface:BrokerThrow an exception if there is no transaction active and nontransactional reading is not enabled.- Specified by:
assertNontransactionalReadin interfaceBroker
-
assertWriteOperation
public void assertWriteOperation()Description copied from interface:BrokerThrow an exception if a write operation is not permitted (there is no active transaction and nontransactional writing is not enabled).- Specified by:
assertWriteOperationin interfaceBroker
-
processArgument
Description copied from interface:FindCallbacksProcess find argument. Throw properOpenJPAExceptionfor illegal value.- Specified by:
processArgumentin interfaceFindCallbacks- Returns:
- the id to look up, or null to ignore this argument
-
processReturn
Description copied from interface:FindCallbacksProcess operation return value.- Specified by:
processReturnin interfaceFindCallbacks- Returns:
- the object to return
-
getPrintParameters
public boolean getPrintParameters()- Returns:
- The value of openjpa.ConnectionFactoryProperties.PrintParameters. Default is false.
-
assignObjectId
Assign the object id to the cache. Exception will be thrown if the id already exists in the cache. -
checkForDuplicateId
This method makes sure we don't already have the instance cached -
getCachePreparedQuery
public boolean getCachePreparedQuery()Description copied from interface:BrokerAffirms if this receiver is caching prepared queries.- Specified by:
getCachePreparedQueryin interfaceBroker
-
setCachePreparedQuery
public void setCachePreparedQuery(boolean flag) Description copied from interface:BrokerSets 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:
setCachePreparedQueryin interfaceBroker
-
getCacheFinderQuery
public boolean getCacheFinderQuery() -
setCacheFinderQuery
public void setCacheFinderQuery(boolean flag) -
isFromWriteBehindCallback
public boolean isFromWriteBehindCallback() -
getConnectionFactoryName
Return the 'JTA' connectionFactoryName- Specified by:
getConnectionFactoryNamein interfaceStoreContext
-
setConnectionFactoryName
Set the 'JTA' ConnectionFactoryName. Input will be trimmed to null before being stored.- Specified by:
setConnectionFactoryNamein interfaceStoreContext
-
getConnectionFactory2Name
Return the 'NonJTA' ConnectionFactoryName.- Specified by:
getConnectionFactory2Namein interfaceStoreContext
-
setConnectionFactory2Name
Set the 'NonJTA' ConnectionFactoryName. Input will be trimmed to null before being stored.- Specified by:
setConnectionFactory2Namein interfaceStoreContext
-
getConnectionFactory
Return the 'JTA' ConnectionFactory, looking it up from JNDI if needed.- Specified by:
getConnectionFactoryin interfaceStoreContext- Returns:
- the JTA connection factory or null if connectionFactoryName is blank.
-
getConnectionFactory2
Return the 'NonJTA' ConnectionFactory, looking it up from JNDI if needed.- Specified by:
getConnectionFactory2in interfaceStoreContext- Returns:
- the NonJTA connection factory or null if connectionFactoryName is blank.
-
isCached
Description copied from interface:StoreContextIndicate whether the oid can be found in the StoreContext's L1 cache or in the StoreManager cache.- Specified by:
isCachedin 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:StoreContextAffirms if this context will allow its managed instances to refer instances that are managed by other contexts.- Specified by:
getAllowReferenceToSiblingContextin interfaceStoreContext- Returns:
- false by default.
-
setAllowReferenceToSiblingContext
public void setAllowReferenceToSiblingContext(boolean allow) Description copied from interface:StoreContextAffirms 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:
setAllowReferenceToSiblingContextin interfaceStoreContext
-
isFlushing
protected boolean isFlushing() -
getPostLoadOnMerge
public boolean getPostLoadOnMerge()Description copied from interface:StoreContextForce sending a @PostLoad lifecycle event while merging.- Specified by:
getPostLoadOnMergein interfaceStoreContext- Returns:
falseby default
-
setPostLoadOnMerge
public void setPostLoadOnMerge(boolean allow) Description copied from interface:StoreContextSet totrueif the merge operation should trigger a @PostLoad lifecycle event.- Specified by:
setPostLoadOnMergein interfaceStoreContext- Parameters:
allow- PostLoad lifecycle events to be triggered on a merge operation
-