- 
- All Superinterfaces:
- ExecutionContextReference
 - All Known Implementing Classes:
- ExecutionContextImpl,- ExecutionContextThreadedImpl
 
 public interface ExecutionContext extends ExecutionContextReference Context of execution for persistence operations. This equates to the work of a PersistenceManager/EntityManager. An ExecutionContext is responsible for- persist, merge, find and delete of persistable objects from the defined StoreManager
- have a set of properties defining behaviour over and above the default configuration of the parent NucleusContext
- provide an interface to querying of the persistable objects in the StoreManager
- provide a way of managing persistable objects using StateManagers
- have a cache of currently managed objects (the "Level 1" cache), and make use of the cache of the parent NucleusContext when not available in its cache
- have a single "current" transaction. This transaction can be local, or JTA
 An ExecutionContext can be started with a series of options that affect its behaviour thereafter. These are defined by the "OPTION_{YYY}" static Strings. 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static classExecutionContext.EmbeddedOwnerRelationstatic interfaceExecutionContext.LifecycleListenerInterface to be implemented by a listener for the closure of the ExecutionContext.
 - 
Field SummaryFields Modifier and Type Field Description static StringOPTION_JTA_AUTOJOINStartup option setting whether, when using JTA, to do auto-join of transactions.static StringOPTION_PASSWORDStartup option overriding the default (PMF/EMF) password for the connectionURL.static StringOPTION_USERNAMEStartup option overriding the default (PMF/EMF) username for the connectionURL.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddInternalFetchGroup(FetchGroup grp)Method to add an internal fetch group to this ExecutionContext.voidaddOperationToQueue(Operation oper)Method to add an operation to the queue.voidaddStateManagerToCache(DNStateManager sm)Method to add the object managed by the specified StateManager to the cache.voidassertClassPersistable(Class cls)Convenience method to assert if the passed class is not persistable.voidattachObject(DNStateManager sm, Object pc, boolean sco)Method to attach the passed object (and related objects).<T> TattachObjectCopy(DNStateManager sm, T pc, boolean sco)Method to attach a copy of the passed object (and related objects).voidclearDirty()Method to mark as clean all StateManagers of dirty objects.voidclearDirty(DNStateManager sm)Mark the specified StateManager as clean.voidclose()Method to close the execution context.voidcloseCallbackHandler()Close the callback handler, and disconnect any registered instance listeners.booleancontainsStateManagerAssociatedValue(DNStateManager sm, Object key)voiddeleteObject(Object obj)Method to delete an object from the datastore.voiddeleteObjectInternal(Object pc)Method to delete the passed object (internally).voiddeleteObjects(Object... objs)Method to delete an array of objects from the datastore.voidderegisterEmbeddedRelation(ExecutionContext.EmbeddedOwnerRelation rel)Method to deregister the specified embedded relation (e.g when the embedded object is disconnected).voidderegisterExecutionContextListener(ExecutionContextListener listener)Deregister a listener from calling when this ExecutionContext is closing.voiddetachAll()Method to detach all managed objects.voiddetachObject(FetchPlanState state, Object pc)Method to detach the passed object.<T> TdetachObjectCopy(FetchPlanState state, T pc)Method to detach a copy of the passed object using the provided state.voiddetachObjects(FetchPlanState state, Object... pcs)Method to detach the passed object(s).voidenlistInTransaction(DNStateManager sm)Method to enlist the specified StateManager in the current transaction.voidevictAllObjects()Method to evict all L1 cache objectsvoidevictFromTransaction(DNStateManager sm)Method to evict the specified StateManager from the current transaction.voidevictObject(Object pc)Method to evict the passed object.voidevictObjects(Class cls, boolean subclasses)Method to evict all objects of the specified type (and optionaly its subclasses).booleanexists(Object obj)Method to return if the specified object exists in the datastore.<T> TfindObject(Class<T> cls, Object key)Accessor for an object of the specified type with the provided id "key".PersistablefindObject(Object id, boolean validate)Shortcut to calling "findObject(id, validate, validate, null)".PersistablefindObject(Object id, boolean validate, boolean checkInheritance, String objectClassName)Accessor for an object given the object id.PersistablefindObject(Object id, FieldValues fv, Class pcClass, boolean ignoreCache, boolean checkInheritance)Accessor for an object given the object id.<T> TfindObjectByUnique(Class<T> cls, String[] fieldNames, Object[] fieldValues)Accessor for an object of the specified type with the provided values for a unique key.<T> List<T>findObjects(Class<T> cls, List keys)Accessor for objects of the specified type, with the provided id "key"s.Persistable[]findObjectsById(Object[] ids, boolean validate)Accessor for persistable objects with the specified identities.DNStateManagerfindStateManager(Object pc)Method to find StateManager for the passed persistable object when it is managed by this manager.DNStateManagerfindStateManager(Object pc, boolean persist)Method to find StateManager for the passed persistable object when it is managed by this manager, and if not yet persistent to persist it and return the assigned StateManager.DNStateManagerfindStateManagerForEmbedded(Object value, DNStateManager owner, AbstractMemberMetaData mmd, PersistableObjectType objectType)Method to find StateManager for the passed embedded persistable object.DNStateManagerfindStateManagerOfOwnerForAttachingObject(Object pc)voidflush()Method callable from external APIs for user-management of flushing.voidflushInternal(boolean flushToDatastore)Method to flushes all dirty, new, and deleted instances to the datastore.voidflushOperationsForBackingStore(Store backingStore, DNStateManager sm)Method to flush all queued operations for the specified backing store (if any).default ApiAdaptergetApiAdapter()Accessor for the API adapter.ObjectgetAttachDetachReferencedObject(DNStateManager sm)Access a referenced object for this StateManager during the attach/detach process.ObjectgetAttachedObjectForId(Object id)Convenience method to return the attached object for the specified id if one exists.BooleangetBooleanProperty(String name)Accessor for a boolean property value.CallbackHandlergetCallbackHandler()Retrieve the callback handler for this ExecutionContext.ClassLoaderResolvergetClassLoaderResolver()Accessor for the ClassLoader resolver to use in class loading issues.StringgetCurrentUser()Accessor for the current user, for this ExecutionContext.List<ExecutionContext.EmbeddedOwnerRelation>getEmbeddedInformationForOwner(DNStateManager ownerSM)Accessor for the relations for the specified embedded StateManager where it is embedded.<T> Extent<T>getExtent(Class<T> candidateClass, boolean includeSubclasses)Accessor for the Extent for a class (and optionally its subclasses).Set<FetchGroup>getFetchGroupsWithName(String name)Accessor for the fetch groups for the specified name.FetchPlangetFetchPlan()Acessor for the current FetchPlanFlushModegetFlushMode()Accessor for the flush mode.FetchGroupgetInternalFetchGroup(Class cls, String name)Accessor for an internal fetch group for the specified class.IntegergetIntProperty(String name)Accessor for an int property value.Level1CachegetLevel1Cache()LockManagergetLockManager()Accessor for the lock manager for objects in this execution context.SetgetManagedObjects()Accessor for the currently managed objects for the current transaction.SetgetManagedObjects(Class[] classes)Accessor for the currently managed objects for the current transaction.SetgetManagedObjects(String[] states)Accessor for the currently managed objects for the current transaction.SetgetManagedObjects(String[] states, Class[] classes)Accessor for the currently managed objects for the current transaction.booleangetManageRelations()Whether managed relations are supported by this execution context.default MetaDataManagergetMetaDataManager()Accessor for the MetaData Manager.booleangetMultithreaded()Accessor for whether this context is multithreaded.PersistenceNucleusContextgetNucleusContext()Accessor for the context in which this execution context is running.PersistablegetObjectFromCache(Object id)Convenience method to access an object in the cache.Persistable[]getObjectsFromCache(Object[] ids)Convenience method to access objects in the cache.List<DNStateManager>getObjectsToBeFlushed()Convenience method to inspect the list of objects with outstanding changes to flush.OperationQueuegetOperationQueue()Accessor for the operation queue.DNStateManagergetOwnerForEmbeddedStateManager(DNStateManager embSM)Accessor for the owner StateManager for the provided embedded StateManager.ExecutionContext.EmbeddedOwnerRelationgetOwnerInformationForEmbedded(DNStateManager embSM)Accessor for the owner relation for the specified embedded StateManager where it is embedded.Map<String,Object>getProperties()Accessor for the defined properties.ObjectgetProperty(String name)Accessor for a property.RelationshipManagergetRelationshipManager(DNStateManager sm)Accessor for the RelationshipManager for the provided StateManager.booleangetSerializeReadForClass(String className)Convenience method to return the setting for serialize read for the current transaction for the specified class name.ObjectgetStateManagerAssociatedValue(DNStateManager sm, Object key)ManagerStatisticsgetStatistics()Accessor for any statistics-gathering object.default StoreManagergetStoreManager()Accessor for the Store Manager.StringgetStringProperty(String name)Accessor for a String property value.Set<String>getSupportedProperties()Accessor for the supported property names.StringgetTenantId()Accessor for the tenant id, for this ExecutionContext.TransactiongetTransaction()Accessor for the current transaction for this execution context.default TypeManagergetTypeManager()Convenience accessor for the type manager for this persistence context (from NucleusContext).booleanhasIdentityInCache(Object id)Whether an object with the specified identity exists in the cache(s).booleanhasPersistenceInformationForClass(Class cls)Utility method to check if the specified class has reachable metadata or annotations.voidinitialise(Object owner, Map<String,Object> options)booleanisClosed()Accessor for whether this execution context is closed.booleanisDelayDatastoreOperationsEnabled()Whether the datastore operations are delayed until commit.booleanisEnlistedInTransaction(Object id)Method to return if an object is enlisted in the current transaction.booleanisFlushing()Accessor for whether the ExecutionContext is flushing changes to the datastore.booleanisInserting(Object pc)Tests whether this persistable object is being inserted.booleanisManagingRelations()Returns whether this ExecutionContext is currently performing the manage relationships task.booleanisObjectModifiedInTransaction(Object id)Accessor for whether the object with this identity is modified in the current transaction.booleanisRunningDetachAllOnCommit()Accessor for whether this ExecutionContext is currently running detachAllOnCommit.voidmakeObjectNontransactional(Object pc)Method to make the passed object nontransactional.voidmakeObjectTransactional(Object pc)Method to make the passed object transactional.voidmakeObjectTransient(Object pc, FetchPlanState state)Method to make transient the passed object.voidmarkDirty(DNStateManager sm, boolean directUpdate)Mark the specified StateManager as dirtyvoidmarkFieldsForUpdateInLevel2Cache(Object id, boolean[] fields)Method to mark the object with specifed id to have the supplied fields updated in the L2 cache at commit.<T> TnewInstance(Class<T> cls)Method to generate an instance of an interface, abstract class, or concrete PC class.ObjectnewObjectId(Class pcClass, Object key)This method returns an object id instance corresponding to the pcClass and key arguments.ObjectnewObjectId(String className, Object pc)This method returns an object id instance corresponding to the class name, and the passed object (when using app identity).booleanoperationQueueIsActive()Accessor for whether the operation queue is currently active.<T> TpersistObject(T pc, boolean merging)Method to persist the passed object.<T> TpersistObjectInternal(T pc, DNStateManager ownerSM, int ownerFieldNum, PersistableObjectType objectType)Method to persist the passed object (internally).default <T> TpersistObjectInternal(T pc, FieldValues preInsertChanges, PersistableObjectType objectType)Method to persist the passed object (internally).<T> TpersistObjectInternal(T pc, FieldValues preInsertChanges, DNStateManager ownerSM, int ownerFieldNum, PersistableObjectType objectType)Method to persist the passed object (internally).Object[]persistObjects(Object... pcs)Method to persist the passed object(s).voidprocessNontransactionalUpdate()Method to process any outstanding non-transactional updates that are queued.voidputObjectIntoLevel1Cache(DNStateManager sm)Method to put a Persistable object associated to StateManager into the L1 cache.voidrefreshAllObjects()Method to refresh all L1 cache objectsvoidrefreshObject(Object pc)Method to refresh the passed object.ExecutionContext.EmbeddedOwnerRelationregisterEmbeddedRelation(DNStateManager ownerSM, int ownerMemberNum, PersistableObjectType objectType, DNStateManager embSM)Method to register an embedded relation for the specified member of the owner StateManager where the embedded StateManager is stored.voidregisterExecutionContextListener(ExecutionContextListener listener)Register a listener to be called when this ExecutionContext is closing.voidremoveEmbeddedOwnerRelation(DNStateManager ownerSM, int ownerFieldNum, DNStateManager embSM)Convenience method to remove the EmbeddedOwnerRelation between the specified StateManagers.voidremoveObjectFromLevel1Cache(Object id)Method to remove an object from the L1 cache.voidremoveObjectFromLevel2Cache(Object id)Method to remove an object from the L2 cache.voidremoveStateManagerAssociatedValue(DNStateManager sm, Object key)voidremoveStateManagerFromCache(DNStateManager sm)Method to remove the object managed by the specified StateManager from the cache.voidreplaceObjectId(Persistable pc, Object oldID, Object newID)Replace the previous object id for a PC object to a newvoidretrieveObjects(boolean useFetchPlan, Object... pcs)Method to retrieve the (fields of the) passed object(s).voidsetAttachDetachReferencedObject(DNStateManager sm, Object obj)Register a referenced object against this StateManager for the attach/detach process.voidsetProperties(Map props)Method to set properties on the execution context.voidsetProperty(String name, Object value)Method to set a property on the execution contextvoidsetStateManagerAssociatedValue(DNStateManager sm, Object key, Object value)default voidthreadLock()Method to lock this ExecutionContext for threadingdefault voidthreadUnlock()Method to unlock this ExecutionContext for threading- 
Methods inherited from interface org.datanucleus.enhancement.ExecutionContextReferencegetOwner
 
- 
 
- 
- 
- 
Field Detail- 
OPTION_USERNAMEstatic final String OPTION_USERNAME Startup option overriding the default (PMF/EMF) username for the connectionURL.- See Also:
- Constant Field Values
 
 - 
OPTION_PASSWORDstatic final String OPTION_PASSWORD Startup option overriding the default (PMF/EMF) password for the connectionURL.- See Also:
- Constant Field Values
 
 - 
OPTION_JTA_AUTOJOINstatic final String OPTION_JTA_AUTOJOIN Startup option setting whether, when using JTA, to do auto-join of transactions.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getLevel1CacheLevel1Cache getLevel1Cache() 
 - 
getTransactionTransaction getTransaction() Accessor for the current transaction for this execution context.- Returns:
- The current transaction
 
 - 
getStoreManagerdefault StoreManager getStoreManager() Accessor for the Store Manager.- Returns:
- Store Manager
 
 - 
getMetaDataManagerdefault MetaDataManager getMetaDataManager() Accessor for the MetaData Manager.- Returns:
- The MetaData Manager
 
 - 
getNucleusContextPersistenceNucleusContext getNucleusContext() Accessor for the context in which this execution context is running.- Returns:
- Returns the context.
 
 - 
getApiAdapterdefault ApiAdapter getApiAdapter() Accessor for the API adapter.- Returns:
- API adapter.
 
 - 
getFetchPlanFetchPlan getFetchPlan() Acessor for the current FetchPlan- Returns:
- FetchPlan
 
 - 
getClassLoaderResolverClassLoaderResolver getClassLoaderResolver() Accessor for the ClassLoader resolver to use in class loading issues.- Returns:
- The ClassLoader resolver
 
 - 
getLockManagerLockManager getLockManager() Accessor for the lock manager for objects in this execution context.- Returns:
- The lock manager
 
 - 
getStatisticsManagerStatistics getStatistics() Accessor for any statistics-gathering object.- Returns:
- The statistics for this manager
 
 - 
setPropertiesvoid setProperties(Map props) Method to set properties on the execution context.- Parameters:
- props- The properties
 
 - 
setPropertyvoid setProperty(String name, Object value) Method to set a property on the execution context- Parameters:
- name- Name of the property
- value- Value to set
 
 - 
getPropertyObject getProperty(String name) Accessor for a property.- Parameters:
- name- Name of the property
- Returns:
- The value
 
 - 
getBooleanPropertyBoolean getBooleanProperty(String name) Accessor for a boolean property value.- Parameters:
- name- Name of the property
- Returns:
- the value
 
 - 
getIntPropertyInteger getIntProperty(String name) Accessor for an int property value.- Parameters:
- name- Name of the property
- Returns:
- the value
 
 - 
getStringPropertyString getStringProperty(String name) Accessor for a String property value.- Parameters:
- name- Name of the property
- Returns:
- The value
 
 - 
getPropertiesMap<String,Object> getProperties() Accessor for the defined properties.- Returns:
- Properties for this execution context
 
 - 
getSupportedPropertiesSet<String> getSupportedProperties() Accessor for the supported property names.- Returns:
- Set of names
 
 - 
getTypeManagerdefault TypeManager getTypeManager() Convenience accessor for the type manager for this persistence context (from NucleusContext).- Returns:
- The type manager
 
 - 
closevoid close() Method to close the execution context.
 - 
isClosedboolean isClosed() Accessor for whether this execution context is closed.- Returns:
- Whether this manager is closed.
 
 - 
findStateManagerDNStateManager findStateManager(Object pc) Method to find StateManager for the passed persistable object when it is managed by this manager.- Parameters:
- pc- The persistable object
- Returns:
- StateManager
 
 - 
findStateManagerDNStateManager findStateManager(Object pc, boolean persist) Method to find StateManager for the passed persistable object when it is managed by this manager, and if not yet persistent to persist it and return the assigned StateManager.- Parameters:
- pc- The persistable object
- persist- Whether to persist if not yet persistent
- Returns:
- StateManager
 
 - 
findStateManagerForEmbeddedDNStateManager findStateManagerForEmbedded(Object value, DNStateManager owner, AbstractMemberMetaData mmd, PersistableObjectType objectType) Method to find StateManager for the passed embedded persistable object. Will create one if not already registered, and tie it to the specified owner.- Parameters:
- value- The embedded object
- owner- The owner StateManager (if known).
- mmd- Metadata for the field of the owner
- objectType- Type of persistable object being stored
- Returns:
- StateManager for the embedded object
 
 - 
findStateManagerOfOwnerForAttachingObjectDNStateManager findStateManagerOfOwnerForAttachingObject(Object pc) 
 - 
addStateManagerToCachevoid addStateManagerToCache(DNStateManager sm) Method to add the object managed by the specified StateManager to the cache.- Parameters:
- sm- StateManager
 
 - 
removeStateManagerFromCachevoid removeStateManagerFromCache(DNStateManager sm) Method to remove the object managed by the specified StateManager from the cache.- Parameters:
- sm- StateManager
 
 - 
evictObjectvoid evictObject(Object pc) Method to evict the passed object.- Parameters:
- pc- The object
 
 - 
evictObjectsvoid evictObjects(Class cls, boolean subclasses) Method to evict all objects of the specified type (and optionaly its subclasses).- Parameters:
- cls- Type of persistable object
- subclasses- Whether to include subclasses
 
 - 
evictAllObjectsvoid evictAllObjects() Method to evict all L1 cache objects
 - 
retrieveObjectsvoid retrieveObjects(boolean useFetchPlan, Object... pcs)Method to retrieve the (fields of the) passed object(s).- Parameters:
- useFetchPlan- Whether to retrieve the current fetch plan
- pcs- The objects
 
 - 
persistObject<T> T persistObject(T pc, boolean merging)Method to persist the passed object.- Type Parameters:
- T- Type of the persistable object
- Parameters:
- pc- The object
- merging- Whether this object (and dependents) is being merged
- Returns:
- The persisted object
 
 - 
persistObjectsObject[] persistObjects(Object... pcs) Method to persist the passed object(s).- Parameters:
- pcs- The objects to persist
- Returns:
- The persisted objects
 
 - 
persistObjectInternal<T> T persistObjectInternal(T pc, FieldValues preInsertChanges, DNStateManager ownerSM, int ownerFieldNum, PersistableObjectType objectType)Method to persist the passed object (internally).- Type Parameters:
- T- Type of the persistable object
- Parameters:
- pc- The object
- preInsertChanges- Changes to be made before inserting
- ownerSM- StateManager of the owner when embedded
- ownerFieldNum- Field number in the owner where this is embedded (or -1 if not embedded)
- objectType- Type of object
- Returns:
- The persisted object
 
 - 
persistObjectInternal<T> T persistObjectInternal(T pc, DNStateManager ownerSM, int ownerFieldNum, PersistableObjectType objectType)Method to persist the passed object (internally).- Type Parameters:
- T- Type of the persistable object
- Parameters:
- pc- The object
- ownerSM- StateManager of the owner when embedded
- ownerFieldNum- Field number in the owner where this is embedded (or -1 if not embedded)
- objectType- Type of object
- Returns:
- The persisted object
 
 - 
persistObjectInternaldefault <T> T persistObjectInternal(T pc, FieldValues preInsertChanges, PersistableObjectType objectType)Method to persist the passed object (internally).- Type Parameters:
- T- Type of the persistable object
- Parameters:
- pc- The object
- preInsertChanges- Changes to be made before inserting
- objectType- Type of object
- Returns:
- The persisted object
 
 - 
makeObjectTransientvoid makeObjectTransient(Object pc, FetchPlanState state) Method to make transient the passed object.- Parameters:
- pc- The object
- state- Object containing the state of the fetchplan processing
 
 - 
makeObjectTransactionalvoid makeObjectTransactional(Object pc) Method to make the passed object transactional.- Parameters:
- pc- The object
 
 - 
makeObjectNontransactionalvoid makeObjectNontransactional(Object pc) Method to make the passed object nontransactional.- Parameters:
- pc- The object
 
 - 
existsboolean exists(Object obj) Method to return if the specified object exists in the datastore.- Parameters:
- obj- The (persistable) object
- Returns:
- Whether it exists
 
 - 
getManagedObjectsSet getManagedObjects() Accessor for the currently managed objects for the current transaction. If the transaction is not active this returns null.- Returns:
- Collection of managed objects enlisted in the current transaction
 
 - 
getManagedObjectsSet getManagedObjects(Class[] classes) Accessor for the currently managed objects for the current transaction. If the transaction is not active this returns null.- Parameters:
- classes- Classes that we want the objects for
- Returns:
- Collection of managed objects enlisted in the current transaction
 
 - 
getManagedObjectsSet getManagedObjects(String[] states) Accessor for the currently managed objects for the current transaction. If the transaction is not active this returns null.- Parameters:
- states- States that we want the objects for
- Returns:
- Collection of managed objects enlisted in the current transaction
 
 - 
getManagedObjectsSet getManagedObjects(String[] states, Class[] classes) Accessor for the currently managed objects for the current transaction. If the transaction is not active this returns null.- Parameters:
- states- States that we want the objects for
- classes- Classes that we want the objects for
- Returns:
- Collection of managed objects enlisted in the current transaction
 
 - 
deleteObjectvoid deleteObject(Object obj) Method to delete an object from the datastore.- Parameters:
- obj- The object
 
 - 
deleteObjectsvoid deleteObjects(Object... objs) Method to delete an array of objects from the datastore.- Parameters:
- objs- The objects to delete
 
 - 
deleteObjectInternalvoid deleteObjectInternal(Object pc) Method to delete the passed object (internally).- Parameters:
- pc- The object
 
 - 
detachObjectvoid detachObject(FetchPlanState state, Object pc) Method to detach the passed object.- Parameters:
- state- State for the detachment process.
- pc- The object to detach
 
 - 
detachObjectsvoid detachObjects(FetchPlanState state, Object... pcs) Method to detach the passed object(s).- Parameters:
- state- State for the detachment process.
- pcs- The object(s) to detach
 
 - 
detachObjectCopy<T> T detachObjectCopy(FetchPlanState state, T pc) Method to detach a copy of the passed object using the provided state.- Type Parameters:
- T- Type of the persistable object
- Parameters:
- state- State for the detachment process
- pc- The object
- Returns:
- The detached copy of the object
 
 - 
detachAllvoid detachAll() Method to detach all managed objects.
 - 
attachObjectvoid attachObject(DNStateManager sm, Object pc, boolean sco) Method to attach the passed object (and related objects). Throws an exception if another (persistent) object with the same id exists in the L1 cache already.- Parameters:
- sm- StateManager of the owning object that has this in a field causing its attach
- pc- The (detached) object
- sco- Whether the object has no identity (embedded or serialised)
 
 - 
attachObjectCopy<T> T attachObjectCopy(DNStateManager sm, T pc, boolean sco) Method to attach a copy of the passed object (and related objects).- Type Parameters:
- T- Type of the persistable object
- Parameters:
- sm- StateManager of the owning object that has this in a field causing its attach
- pc- The object
- sco- Whether it has no identity (second-class object)
- Returns:
- The attached copy of the input object
 
 - 
getAttachedObjectForIdObject getAttachedObjectForId(Object id) Convenience method to return the attached object for the specified id if one exists.- Parameters:
- id- The id
- Returns:
- The attached object
 
 - 
refreshObjectvoid refreshObject(Object pc) Method to refresh the passed object.- Parameters:
- pc- The object
 
 - 
refreshAllObjectsvoid refreshAllObjects() Method to refresh all L1 cache objects
 - 
enlistInTransactionvoid enlistInTransaction(DNStateManager sm) Method to enlist the specified StateManager in the current transaction.- Parameters:
- sm- StateManager
 
 - 
isEnlistedInTransactionboolean isEnlistedInTransaction(Object id) Method to return if an object is enlisted in the current transaction.- Parameters:
- id- Identity for the object
- Returns:
- Whether it is enlisted in the current transaction
 
 - 
evictFromTransactionvoid evictFromTransaction(DNStateManager sm) Method to evict the specified StateManager from the current transaction.- Parameters:
- sm- StateManager
 
 - 
markDirtyvoid markDirty(DNStateManager sm, boolean directUpdate) Mark the specified StateManager as dirty- Parameters:
- sm- StateManager
- directUpdate- Whether the object has had a direct update made on it (if known)
 
 - 
clearDirtyvoid clearDirty(DNStateManager sm) Mark the specified StateManager as clean.- Parameters:
- sm- StateManager
 
 - 
clearDirtyvoid clearDirty() Method to mark as clean all StateManagers of dirty objects.
 - 
processNontransactionalUpdatevoid processNontransactionalUpdate() Method to process any outstanding non-transactional updates that are queued. If "datanucleus.nontx.atomic" is false, or currently in a transaction then returns immediately. Otherwise will flush any updates that are outstanding (updates to an object), will perform detachAllOnCommit if enabled (so user always has detached objects), update objects in any L2 cache, and migrates any objects through lifecycle changes. Is similar in content to "flush"+"preCommit"+"postCommit"
 - 
findObject<T> T findObject(Class<T> cls, Object key) Accessor for an object of the specified type with the provided id "key". With datastore id or single-field id the "key" is the key of the id, and with composite ids the "key" is the toString() of the id.- Type Parameters:
- T- Type of the persistable
- Parameters:
- cls- Class of the persistable
- key- Value of the key field for SingleFieldIdentity, or the string value of the key otherwise
- Returns:
- The object meeting this requirement
 
 - 
findObjects<T> List<T> findObjects(Class<T> cls, List keys) Accessor for objects of the specified type, with the provided id "key"s. With datastore id or single-field id the "key" is the key of the id, and with composite ids the "key" is the toString() of the id.- Type Parameters:
- T- Type of the persistable
- Parameters:
- cls- Class of the persistable
- keys- Values of the key field for SingleFieldIdentity, or the string value of the keys otherwise
- Returns:
- The objects meeting this requirement
 
 - 
findObjectByUnique<T> T findObjectByUnique(Class<T> cls, String[] fieldNames, Object[] fieldValues) Accessor for an object of the specified type with the provided values for a unique key. Alternative would be to have an intermediate class and do thisec.findObjectByUnique(cls).for("field1", val1).for("field2", val2).find();- Type Parameters:
- T- Type of the persistable
- Parameters:
- cls- Class of the persistable
- fieldNames- Name(s) of the field(s) forming the unique key
- fieldValues- Value(s) of the field(s) forming the unique key
- Returns:
- The object meeting this requirement
 
 - 
findObjectPersistable findObject(Object id, boolean validate) Shortcut to calling "findObject(id, validate, validate, null)". Note: This is used by the bytecode enhancement contract indnCopyKeyFieldsFromObjectId - Specified by:
- findObjectin interface- ExecutionContextReference
- Parameters:
- id- The id of the object
- validate- Whether to validate the id
- Returns:
- The object
 
 - 
findObjectsByIdPersistable[] findObjectsById(Object[] ids, boolean validate) Accessor for persistable objects with the specified identities.- Parameters:
- ids- Ids of the object(s).
- validate- Whether to validate the object state
- Returns:
- The persistable objects with these ids (same order)
- Throws:
- NucleusObjectNotFoundException- if an object doesn't exist in the datastore
 
 - 
findObjectPersistable findObject(Object id, boolean validate, boolean checkInheritance, String objectClassName) Accessor for an object given the object id.- Parameters:
- id- Id of the object.
- validate- Whether to validate the object state
- checkInheritance- Whether look to the database to determine which class this object is. This parameter is a hint. Set false, if it's already determined the correct pcClass for this pc "object" in a certain level in the hierarchy. Set to true and it will look to the database.
- objectClassName- Class name for the object with this id (if known, optional)
- Returns:
- The Object
 
 - 
findObjectPersistable findObject(Object id, FieldValues fv, Class pcClass, boolean ignoreCache, boolean checkInheritance) Accessor for an object given the object id. Typically used after a query to apply the retrieved values to an object.- Parameters:
- id- Id of the object.
- fv- FieldValues to apply to the object (optional)
- pcClass- the type which the object is. This type will be used to instantiate the object
- ignoreCache- true if the cache is ignored
- checkInheritance- Whether to check the inheritance of this object
- Returns:
- the Object
 
 - 
getExtent<T> Extent<T> getExtent(Class<T> candidateClass, boolean includeSubclasses) Accessor for the Extent for a class (and optionally its subclasses).- Type Parameters:
- T- Type of the persistable object
- Parameters:
- candidateClass- The class
- includeSubclasses- Whether to include subclasses
- Returns:
- The Extent
 
 - 
putObjectIntoLevel1Cachevoid putObjectIntoLevel1Cache(DNStateManager sm) Method to put a Persistable object associated to StateManager into the L1 cache.- Parameters:
- sm- StateManager
 
 - 
getObjectFromCachePersistable getObjectFromCache(Object id) Convenience method to access an object in the cache. Firstly looks in the L1 cache for this ExecutionContext, and if not found looks in the L2 cache.- Parameters:
- id- Id of the object
- Returns:
- Persistable object (with connected StateManager).
 
 - 
getObjectsFromCachePersistable[] getObjectsFromCache(Object[] ids) Convenience method to access objects in the cache. Firstly looks in the L1 cache, and if not found looks in the L2 cache.- Parameters:
- ids- Ids of the objects
- Returns:
- Persistable objects (with connected StateManager).
 
 - 
removeObjectFromLevel1Cachevoid removeObjectFromLevel1Cache(Object id) Method to remove an object from the L1 cache.- Parameters:
- id- The id of the object
 
 - 
removeObjectFromLevel2Cachevoid removeObjectFromLevel2Cache(Object id) Method to remove an object from the L2 cache.- Parameters:
- id- The id of the object
 
 - 
markFieldsForUpdateInLevel2Cachevoid markFieldsForUpdateInLevel2Cache(Object id, boolean[] fields) Method to mark the object with specifed id to have the supplied fields updated in the L2 cache at commit.- Parameters:
- id- Id of the object
- fields- The fields to update
 
 - 
hasIdentityInCacheboolean hasIdentityInCache(Object id) Whether an object with the specified identity exists in the cache(s). Used as a check on identity (inheritance-level) validity- Parameters:
- id- The identity
- Returns:
- Whether it exists
 
 - 
newObjectIdObject newObjectId(Class pcClass, Object key) This method returns an object id instance corresponding to the pcClass and key arguments. Operates in 2 modes :-- The class uses SingleFieldIdentity and the key is the value of the key field
- In all other cases the key is the String form of the object id instance
 - Parameters:
- pcClass- Class of the persistable object to create the identity for
- key- Value of the key for SingleFieldIdentity (or the toString value)
- Returns:
- The new object-id instance
 
 - 
newObjectIdObject newObjectId(String className, Object pc) This method returns an object id instance corresponding to the class name, and the passed object (when using app identity).- Parameters:
- className- Name of the class of the object.
- pc- The persistable object. Used for application-identity
- Returns:
- A new object ID.
 
 - 
getSerializeReadForClassboolean getSerializeReadForClass(String className) Convenience method to return the setting for serialize read for the current transaction for the specified class name. Returns the setting for the transaction (if set), otherwise falls back to the setting for the class, otherwise returns false.- Parameters:
- className- Name of the class
- Returns:
- Setting for serialize read
 
 - 
assertClassPersistablevoid assertClassPersistable(Class cls) Convenience method to assert if the passed class is not persistable.- Parameters:
- cls- The class of which we want to persist objects
- Throws:
- ClassNotPersistableException- When the class is not persistable
- NoPersistenceInformationException- When the class has no available persistence information
 
 - 
hasPersistenceInformationForClassboolean hasPersistenceInformationForClass(Class cls) Utility method to check if the specified class has reachable metadata or annotations.- Parameters:
- cls- The class to check
- Returns:
- Whether the class has reachable metadata or annotations
 
 - 
isInsertingboolean isInserting(Object pc) Tests whether this persistable object is being inserted.- Parameters:
- pc- the object to verify the status
- Returns:
- true if this instance is inserting.
 
 - 
isFlushingboolean isFlushing() Accessor for whether the ExecutionContext is flushing changes to the datastore.- Returns:
- Whether it is currently flushing
 
 - 
getFlushModeFlushMode getFlushMode() Accessor for the flush mode. Whether to auto-commit, or whether to delay flushing.- Returns:
- The flush mode.
 
 - 
isDelayDatastoreOperationsEnabledboolean isDelayDatastoreOperationsEnabled() Whether the datastore operations are delayed until commit. In optimistic transactions this is automatically enabled.- Returns:
- true if datastore operations are delayed until commit
 
 - 
isRunningDetachAllOnCommitboolean isRunningDetachAllOnCommit() Accessor for whether this ExecutionContext is currently running detachAllOnCommit.- Returns:
- Whether running detachAllOnCommit
 
 - 
flushvoid flush() Method callable from external APIs for user-management of flushing. Called by JDO PM.flush, or JPA EM.flush(). Performs management of relations, prior to performing internal flush of all dirty/new/deleted instances to the datastore.
 - 
flushInternalvoid flushInternal(boolean flushToDatastore) Method to flushes all dirty, new, and deleted instances to the datastore. It has no effect if a transaction is not active. If a datastore transaction is active, this method synchronizes the cache with the datastore and reports any exceptions. If an optimistic transaction is active, this method obtains a datastore connection and synchronizes the cache with the datastore using this connection. The connection obtained by this method is held until the end of the transaction.- Parameters:
- flushToDatastore- Whether to ensure any changes reach the datastore Otherwise they will be flushed to the datastore manager and leave it to decide the opportune moment to actually flush them to teh datastore
- Throws:
- NucleusOptimisticException- when optimistic locking error(s) occur
 
 - 
getOperationQueueOperationQueue getOperationQueue() Accessor for the operation queue. The queue can be null if there are no operations queued (txn not active, not optimistic, no ops arrived yet).- Returns:
- The operation queue (typically for collections/maps)
 
 - 
operationQueueIsActiveboolean operationQueueIsActive() Accessor for whether the operation queue is currently active. Will return false if not delaying flush, or not in a transaction, or flushing.- Returns:
- Whether the operation queue is active for adding operations
 
 - 
addOperationToQueuevoid addOperationToQueue(Operation oper) Method to add an operation to the queue.- Parameters:
- oper- The operation to add
 
 - 
flushOperationsForBackingStorevoid flushOperationsForBackingStore(Store backingStore, DNStateManager sm) Method to flush all queued operations for the specified backing store (if any).- Parameters:
- backingStore- The backing store
- sm- StateManager
 
 - 
getObjectsToBeFlushedList<DNStateManager> getObjectsToBeFlushed() Convenience method to inspect the list of objects with outstanding changes to flush.- Returns:
- StateManagers for the objects to be flushed.
 
 - 
getMultithreadedboolean getMultithreaded() Accessor for whether this context is multithreaded.- Returns:
- Whether multithreaded (and hence needing locking)
 
 - 
getManageRelationsboolean getManageRelations() Whether managed relations are supported by this execution context.- Returns:
- Supporting managed relations
 
 - 
getRelationshipManagerRelationshipManager getRelationshipManager(DNStateManager sm) Accessor for the RelationshipManager for the provided StateManager.- Parameters:
- sm- StateManager
- Returns:
- The RelationshipManager
 
 - 
isManagingRelationsboolean isManagingRelations() Returns whether this ExecutionContext is currently performing the manage relationships task.- Returns:
- Whether in the process of managing relations
 
 - 
getCallbackHandlerCallbackHandler getCallbackHandler() Retrieve the callback handler for this ExecutionContext.- Returns:
- the callback handler
 
 - 
getInternalFetchGroupFetchGroup getInternalFetchGroup(Class cls, String name) Accessor for an internal fetch group for the specified class.- Parameters:
- cls- The class
- name- Name of the group
- Returns:
- The FetchGroup
 
 - 
addInternalFetchGroupvoid addInternalFetchGroup(FetchGroup grp) Method to add an internal fetch group to this ExecutionContext.- Parameters:
- grp- The internal fetch group
 
 - 
getFetchGroupsWithNameSet<FetchGroup> getFetchGroupsWithName(String name) Accessor for the fetch groups for the specified name.- Parameters:
- name- Name of the group
- Returns:
- The FetchGroup
 
 - 
getTenantIdString getTenantId() Accessor for the tenant id, for this ExecutionContext.- Returns:
- The tenant id for this context.
 
 - 
getCurrentUserString getCurrentUser() Accessor for the current user, for this ExecutionContext.- Returns:
- The current user for this context
 
 - 
threadLockdefault void threadLock() Method to lock this ExecutionContext for threading
 - 
threadUnlockdefault void threadUnlock() Method to unlock this ExecutionContext for threading
 - 
newInstance<T> T newInstance(Class<T> cls) Method to generate an instance of an interface, abstract class, or concrete PC class.- Type Parameters:
- T- Type of the persistable object
- Parameters:
- cls- The class of the interface or abstract class, or concrete class defined in MetaData
- Returns:
- The instance of this type
 
 - 
isObjectModifiedInTransactionboolean isObjectModifiedInTransaction(Object id) Accessor for whether the object with this identity is modified in the current transaction.- Parameters:
- id- The identity.
- Returns:
- Whether it is modified/new/deleted in this transaction
 
 - 
replaceObjectIdvoid replaceObjectId(Persistable pc, Object oldID, Object newID) Replace the previous object id for a PC object to a new- Parameters:
- pc- The Persistable object
- oldID- the old id
- newID- the new id
 
 - 
getAttachDetachReferencedObjectObject getAttachDetachReferencedObject(DNStateManager sm) Access a referenced object for this StateManager during the attach/detach process. When attaching and this is the detached object this returns the newly attached object. When attaching and this is the newly attached object this returns the detached object. When detaching and this is the newly detached object this returns the attached object. When detaching and this is the attached object this returns the newly detached object.- Parameters:
- sm- StateManager
- Returns:
- The referenced object (if any)
 
 - 
setAttachDetachReferencedObjectvoid setAttachDetachReferencedObject(DNStateManager sm, Object obj) Register a referenced object against this StateManager for the attach/detach process.- Parameters:
- sm- StateManager
- obj- The referenced object (or null to clear out any reference)
 
 - 
registerEmbeddedRelationExecutionContext.EmbeddedOwnerRelation registerEmbeddedRelation(DNStateManager ownerSM, int ownerMemberNum, PersistableObjectType objectType, DNStateManager embSM) Method to register an embedded relation for the specified member of the owner StateManager where the embedded StateManager is stored.- Parameters:
- ownerSM- Owner StateManager
- ownerMemberNum- Member number that is embedded
- objectType- Type of object being persisted
- embSM- StateManager of the embedded object
- Returns:
- The EmbeddedOwnerRelation
 
 - 
deregisterEmbeddedRelationvoid deregisterEmbeddedRelation(ExecutionContext.EmbeddedOwnerRelation rel) Method to deregister the specified embedded relation (e.g when the embedded object is disconnected).- Parameters:
- rel- The embedded relation
 
 - 
getEmbeddedInformationForOwnerList<ExecutionContext.EmbeddedOwnerRelation> getEmbeddedInformationForOwner(DNStateManager ownerSM) Accessor for the relations for the specified embedded StateManager where it is embedded.- Parameters:
- ownerSM- StateManager that owns the embedded
- Returns:
- The List of embedded relations involving this StateManager as owner
 
 - 
getOwnerInformationForEmbeddedExecutionContext.EmbeddedOwnerRelation getOwnerInformationForEmbedded(DNStateManager embSM) Accessor for the owner relation for the specified embedded StateManager where it is embedded.- Parameters:
- embSM- StateManager that is embedded
- Returns:
- The embedded relation info involving this (embedded) StateManager
 
 - 
getOwnerForEmbeddedStateManagerDNStateManager getOwnerForEmbeddedStateManager(DNStateManager embSM) Accessor for the owner StateManager for the provided embedded StateManager.- Parameters:
- embSM- StateManager that is embedded
- Returns:
- The owner StateManager that have this object embedded.
 
 - 
removeEmbeddedOwnerRelationvoid removeEmbeddedOwnerRelation(DNStateManager ownerSM, int ownerFieldNum, DNStateManager embSM) Convenience method to remove the EmbeddedOwnerRelation between the specified StateManagers.- Parameters:
- ownerSM- Owner StateManager
- ownerFieldNum- Field in owner
- embSM- Embedded StateManager
 
 - 
setStateManagerAssociatedValuevoid setStateManagerAssociatedValue(DNStateManager sm, Object key, Object value) 
 - 
getStateManagerAssociatedValueObject getStateManagerAssociatedValue(DNStateManager sm, Object key) 
 - 
removeStateManagerAssociatedValuevoid removeStateManagerAssociatedValue(DNStateManager sm, Object key) 
 - 
containsStateManagerAssociatedValueboolean containsStateManagerAssociatedValue(DNStateManager sm, Object key) 
 - 
registerExecutionContextListenervoid registerExecutionContextListener(ExecutionContextListener listener) Register a listener to be called when this ExecutionContext is closing.- Parameters:
- listener- The listener
 
 - 
deregisterExecutionContextListenervoid deregisterExecutionContextListener(ExecutionContextListener listener) Deregister a listener from calling when this ExecutionContext is closing.- Parameters:
- listener- The listener
 
 - 
closeCallbackHandlervoid closeCallbackHandler() Close the callback handler, and disconnect any registered instance listeners. Used by JCA.
 
- 
 
-