org.datanucleus.store
Interface ExecutionContext

All Known Implementing Classes:
MultithreadedObjectManager, ObjectManagerImpl

public interface ExecutionContext

Context of execution for persistence operations. In the traditional Java persistence role this will be an ObjectManager.


Nested Class Summary
static interface ExecutionContext.LifecycleListener
           
 
Method Summary
 void addInternalFetchGroup(FetchGroup grp)
          Method to add an internal fetch group to this ObjectManager.
 void addListener(Object listener, Class[] classes)
          Method to register a listener for instances of the specified classes.
 void addObjectProvider(ObjectProvider op)
          Method to add the object managed by the specified ObjectProvider to the cache.
 void assertClassPersistable(Class cls)
          Convenience method to assert if the passed class is not persistable.
 void attachObject(ObjectProvider op, Object pc, boolean sco)
          Method to attach the passed object (and related objects).
 Object attachObjectCopy(ObjectProvider op, Object pc, boolean sco)
          Method to attach a copy of the passed object (and related objects).
 void clearDirty()
          Method to mark as clean all ObjectProviders of dirty objects.
 void clearDirty(ObjectProvider op)
          Mark the specified ObjectProvider as clean.
 void close()
          Method to close the execution context.
 void deleteObject(Object obj)
          Method to delete an object from the datastore.
 void deleteObjectInternal(Object pc)
          Method to delete the passed object (internally).
 void deleteObjects(Object[] objs)
          Method to delete an array of objects from the datastore.
 void detachAll()
          Method to detach all managed objects.
 void detachObject(Object pc, FetchPlanState state)
          Method to detach the passed object.
 Object detachObjectCopy(Object pc, FetchPlanState state)
          Method to detach a copy of the passed object using the provided state.
 void disconnectLifecycleListener()
          Disconnect the registered LifecycleListener
 void enlistInTransaction(ObjectProvider op)
          Method to enlist the specified ObjectProvider in the current transaction.
 void evictAllObjects()
          Method to evict all L1 cache objects
 void evictFromTransaction(ObjectProvider op)
          Method to evict the specified ObjectProvider from the current transaction.
 void evictObject(Object pc)
          Method to evict the passed object.
 void evictObjects(Class cls, boolean subclasses)
          Method to evict all objects of the specified type (and optionaly its subclasses).
 boolean exists(Object obj)
          Method to return if the specified object exists in the datastore.
 Object findObject(Object id, boolean validate, boolean checkInheritance, String objectClassName)
          Accessor for an object given the object id.
 Object findObject(Object id, FieldValues fv, Class pcClass, boolean ignoreCache, boolean checkInheritance)
          Accessor for an object given the object id.
 ObjectProvider findObjectProvider(Object pc)
          Method to find the ObjectProvider for the passed persistable object when it is managed by this manager.
 ObjectProvider findObjectProvider(Object pc, boolean persist)
          Method to find the ObjectProvider for the passed persistable object when it is managed by this manager, and if not yet persistent to persist it.
 ObjectProvider findObjectProviderForEmbedded(Object value, ObjectProvider owner, AbstractMemberMetaData mmd)
          Method to find the ObjectProvider for the passed embedded persistable object.
 Object[] findObjects(Object[] ids, boolean validate)
          Accessor for objects with the specified identities.
 void flush()
          Method callable from external APIs for user-management of flushing.
 void flushInternal(boolean flushToDatastore)
          Method to flushes all dirty, new, and deleted instances to the datastore.
 ApiAdapter getApiAdapter()
          Accessor for the API adapter.
 Object getAttachedObjectForId(Object id)
          Convenience method to return the attached object for the specified id if one exists.
 Boolean getBooleanProperty(String name)
          Accessor for a boolean property value.
 CallbackHandler getCallbackHandler()
          Retrieve the callback handler for this PM
 ClassLoaderResolver getClassLoaderResolver()
          Accessor for the ClassLoader resolver to use in class loading issues.
 Integer getDatastoreReadTimeoutMillis()
          Accessor for the datastore read timeout in milliseconds.
 Integer getDatastoreWriteTimeoutMillis()
          Accessor for the datastore write timeout in milliseconds.
 Extent getExtent(Class candidateClass, boolean includeSubclasses)
          Accessor for the Extent for a class (and optionally its subclasses).
 Set getFetchGroupsWithName(String name)
          Accessor for the fetch groups for the specified name.
 FetchPlan getFetchPlan()
          Acessor for the current FetchPlan
 boolean getIgnoreCache()
          Accessor for whether to ignore the cache.
 FetchGroup getInternalFetchGroup(Class cls, String name)
          Accessor for an internal fetch group for the specified class.
 Integer getIntProperty(String name)
          Accessor for an int property value.
 Lock getLock()
          Accessor for the lock object for this ObjectManager.
 LockManager getLockManager()
          Accessor for the lock manager for this execution context.
 Set getManagedObjects()
          Accessor for the currently managed objects for the current transaction.
 Set getManagedObjects(Class[] classes)
          Accessor for the currently managed objects for the current transaction.
 Set getManagedObjects(String[] states)
          Accessor for the currently managed objects for the current transaction.
 Set getManagedObjects(String[] states, Class[] classes)
          Accessor for the currently managed objects for the current transaction.
 boolean getManageRelations()
          Whether managed relations are supported by this execution context.
 MetaDataManager getMetaDataManager()
          Accessor for the MetaData Manager.
 boolean getMultithreaded()
          Accessor for whether this context is multithreaded.
 NucleusContext getNucleusContext()
          Accessor for the context in which this execution context is running.
 Object getObjectFromCache(Object id)
          Convenience method to access an object in the cache.
 List<ObjectProvider> getObjectsToBeFlushed()
          Convenience method to inspect the list of objects with outstanding changes to flush.
 Object getOwner()
          Method to return the owner object.
 Map<String,Object> getProperties()
          Accessor for the defined properties.
 Object getProperty(String name)
          Accessor for a property.
 RelationshipManager getRelationshipManager(ObjectProvider op)
          Accessor for the RelationshipManager for the provided ObjectProvider.
 boolean getSerializeReadForClass(String className)
          Convenience method to return the setting for serialize read for the current transaction for the specified class name.
 ManagerStatistics getStatistics()
          Accessor for any statistics-gathering object.
 StoreManager getStoreManager()
          Accessor for the Store Manager.
 Set<String> getSupportedProperties()
          Accessor for the supported property names.
 Transaction getTransaction()
          Accessor for the current transaction for this execution context.
 TypeManager getTypeManager()
          TODO should we keep this here? this is api/language dependent
 boolean hasIdentityInCache(Object id)
          Whether an object with the specified identity exists in the cache(s).
 boolean hasPersistenceInformationForClass(Class cls)
          Utility method to check if the specified class has reachable metadata or annotations.
 void hereIsObjectProvider(ObjectProvider op, Object pc)
          Method to register the ObjectProvider as being for the passed object.
 boolean isClosed()
          Accessor for whether this execution context is closed.
 boolean isDelayDatastoreOperationsEnabled()
          Whether the datastore operations are delayed until commit.
 boolean isEnlistedInTransaction(Object id)
          Method to return if an object is enlisted in the current transaction.
 boolean isFlushing()
          Accessor for whether the ObjectManager is flushing changes to the datastore.
 boolean isInserting(Object pc)
          Tests whether this persistable object is being inserted.
 boolean isManagingRelations()
          Returns whether this ObjectManager is currently performing the manage relationships task.
 boolean isObjectModifiedInTransaction(Object id)
          Accessor for whether the object with this identity is modified in the current transaction.
 boolean isRunningDetachAllOnCommit()
          Accessor for whether this ObjectManager is currently running detachAllOnCommit.
 void makeObjectNontransactional(Object pc)
          Method to make the passed object nontransactional.
 void makeObjectTransactional(Object pc)
          Method to make the passed object transactional.
 void makeObjectTransient(Object pc, FetchPlanState state)
          Method to make transient the passed object.
 void markDirty(ObjectProvider op, boolean directUpdate)
          Mark the specified ObjectProvider as dirty
 Object newInstance(Class cls)
          Method to generate an instance of an interface, abstract class, or concrete PC class.
 Object newObjectId(Class pcClass, Object key)
          This method returns an object id instance corresponding to the pcClass and key arguments.
 Object 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).
 ObjectProvider newObjectProviderForDetached(Object pc, Object id, Object version)
          Constructor for creating ObjectProvider instances to manage persistable objects in detached state.
 ObjectProvider newObjectProviderForEmbedded(AbstractClassMetaData cmd, ObjectProvider ownerOP, int ownerFieldNumber)
          Constructs an ObjectProvider for an object of the specified type, creating the PC object to hold the values where this object will be EMBEDDED/SERIALISED into another persistable object.
 ObjectProvider newObjectProviderForEmbedded(Object pc, boolean copyPc, ObjectProvider ownerOP, int ownerFieldNumber)
          Constructs an ObjectProvider to manage a persistable instance that will be EMBEDDED/SERIALISED into another persistable object.
 ObjectProvider newObjectProviderForHollow(Class pcClass, Object id)
          Constructs an ObjectProvider to manage a hollow instance having the given object ID.
 ObjectProvider newObjectProviderForHollowPopulated(Class pcClass, Object id, FieldValues fv)
          Constructs an ObjectProvider to manage a recently populated hollow instance having the given object ID and the given field values.
 ObjectProvider newObjectProviderForHollowPopulatedAppId(Class pcClass, FieldValues fv)
          Deprecated. Use newForHollowPopulated instead
 ObjectProvider newObjectProviderForHollowPreConstructed(Object id, Object pc)
          Constructs an ObjectProvider to manage a hollow instance having the given object ID.
 ObjectProvider newObjectProviderForPersistentClean(Object id, Object pc)
          Constructs an ObjectProvider to manage the specified persistent instance having the given object ID.
 ObjectProvider newObjectProviderForPersistentNew(Object pc, FieldValues fv)
          Constructs an ObjectProvider to manage a transient instance that is becoming newly persistent.
 ObjectProvider newObjectProviderForPNewToBeDeleted(Object pc)
          Constructor for creating ObjectProvider instances to manage persistable objects that are not persistent yet are about to be deleted.
 ObjectProvider newObjectProviderForTransactionalTransient(Object pc)
          Constructs an ObjectProvider to manage a Transactional Transient instance.
 Query newQuery()
          Accessor for a new Query.
 Object persistObject(Object pc, boolean merging)
          Method to persist the passed object.
 Object persistObjectInternal(Object pc, FieldValues preInsertChanges, int objectType)
          Method to persist the passed object (internally).
 Object persistObjectInternal(Object pc, FieldValues preInsertChanges, ObjectProvider ownerOP, int ownerFieldNum, int objectType)
          Method to persist the passed object (internally).
 Object persistObjectInternal(Object pc, ObjectProvider ownerOP, int ownerFieldNum, int objectType)
          Method to persist the passed object (internally).
 Object[] persistObjects(Object[] pcs)
          Method to persist the passed object(s).
 void processNontransactionalUpdate()
          Method to process any outstanding non-transactional updates that are queued.
 void putObjectIntoLevel1Cache(ObjectProvider op)
          Method to put a Persistable object associated to the ObjectProvider into the L1 cache.
 void refreshAllObjects()
          Method to refresh all L1 cache objects
 void refreshObject(Object pc)
          Method to refresh the passed object.
 void removeListener(Object listener)
          Method to remove a currently registered listener.
 void removeObjectFromLevel1Cache(Object id)
          Method to remove an object from the L1 cache.
 void removeObjectFromLevel2Cache(Object id)
          Method to remove an object from the L2 cache.
 void removeObjectProvider(ObjectProvider op)
          Method to remove the object managed by the specified ObjectProvider from the cache.
 void replaceObjectId(Object pc, Object oldID, Object newID)
          Replace the previous object id for a PC object to a new
 void retrieveObject(Object pc, boolean fgOnly)
          Method to retrieve the passed object.
 void setProperties(Map props)
          Method to set properties on the execution context.
 void setProperty(String name, Object value)
          Method to set a property on the execution context
 

Method Detail

getOwner

Object getOwner()
Method to return the owner object. For JDO this will return the PersistenceManager that owns this object. For JPA this will return the EntityManager that owns this object.

Returns:
The owner manager object

getTransaction

Transaction getTransaction()
Accessor for the current transaction for this execution context.

Returns:
The current transaction

getStoreManager

StoreManager getStoreManager()
Accessor for the Store Manager.

Returns:
Store Manager

getMetaDataManager

MetaDataManager getMetaDataManager()
Accessor for the MetaData Manager.

Returns:
The MetaData Manager

getNucleusContext

NucleusContext getNucleusContext()
Accessor for the context in which this execution context is running.

Returns:
Returns the context.

getApiAdapter

ApiAdapter getApiAdapter()
Accessor for the API adapter.

Returns:
API adapter.

getFetchPlan

FetchPlan getFetchPlan()
Acessor for the current FetchPlan

Returns:
FetchPlan

getClassLoaderResolver

ClassLoaderResolver getClassLoaderResolver()
Accessor for the ClassLoader resolver to use in class loading issues.

Returns:
The ClassLoader resolver

getLockManager

LockManager getLockManager()
Accessor for the lock manager for this execution context.

Returns:
The lock manager

getStatistics

ManagerStatistics getStatistics()
Accessor for any statistics-gathering object.

Returns:
The statistics for this manager

setProperties

void setProperties(Map props)
Method to set properties on the execution context.

Parameters:
props - The properties

setProperty

void setProperty(String name,
                 Object value)
Method to set a property on the execution context

Parameters:
name - Name of the property
value - Value to set

getProperty

Object getProperty(String name)
Accessor for a property.

Parameters:
name - Name of the property
Returns:
The value

getBooleanProperty

Boolean getBooleanProperty(String name)
Accessor for a boolean property value.

Parameters:
name - Name of the property
Returns:
the value

getIntProperty

Integer getIntProperty(String name)
Accessor for an int property value.

Parameters:
name - Name of the property
Returns:
the value

getProperties

Map<String,Object> getProperties()
Accessor for the defined properties.

Returns:
Properties for this execution context

getSupportedProperties

Set<String> getSupportedProperties()
Accessor for the supported property names.

Returns:
Set of names

getTypeManager

TypeManager getTypeManager()
TODO should we keep this here? this is api/language dependent

Returns:
The type manager

close

void close()
Method to close the execution context.


isClosed

boolean isClosed()
Accessor for whether this execution context is closed.

Returns:
Whether this manager is closed.

getIgnoreCache

boolean getIgnoreCache()
Accessor for whether to ignore the cache.

Returns:
Whether to ignore the cache.

getDatastoreReadTimeoutMillis

Integer getDatastoreReadTimeoutMillis()
Accessor for the datastore read timeout in milliseconds.

Returns:
Datastore read timeout in milliseconds (if specified)

getDatastoreWriteTimeoutMillis

Integer getDatastoreWriteTimeoutMillis()
Accessor for the datastore write timeout in milliseconds.

Returns:
Datastore write timeout in milliseconds (if specified)

findObjectProvider

ObjectProvider findObjectProvider(Object pc)
Method to find the ObjectProvider for the passed persistable object when it is managed by this manager.

Parameters:
pc - The persistable object
Returns:
The ObjectProvider

findObjectProvider

ObjectProvider findObjectProvider(Object pc,
                                  boolean persist)
Method to find the ObjectProvider for the passed persistable object when it is managed by this manager, and if not yet persistent to persist it.

Parameters:
pc - The persistable object
persist - Whether to persist if not yet persistent
Returns:
The ObjectProvider

findObjectProviderForEmbedded

ObjectProvider findObjectProviderForEmbedded(Object value,
                                             ObjectProvider owner,
                                             AbstractMemberMetaData mmd)
Method to find the ObjectProvider 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 ObjectProvider (if known).
mmd - Metadata for the field of the owner
Returns:
The ObjectProvider for the embedded object

hereIsObjectProvider

void hereIsObjectProvider(ObjectProvider op,
                          Object pc)
Method to register the ObjectProvider as being for the passed object. Used during the process of identifying ObjectProvider for persistable object.

Parameters:
op - The ObjectProvider
pc - The object managed by the ObjectProvider

newObjectProviderForHollow

ObjectProvider newObjectProviderForHollow(Class pcClass,
                                          Object id)
Constructs an ObjectProvider to manage a hollow instance having the given object ID. This constructor is used for creating new instances of existing persistent objects.

Parameters:
pcClass - the class of the new instance to be created.
id - the JDO identity of the object.

newObjectProviderForHollowPreConstructed

ObjectProvider newObjectProviderForHollowPreConstructed(Object id,
                                                        Object pc)
Constructs an ObjectProvider to manage a hollow instance having the given object ID. The instance is already supplied.

Parameters:
id - the JDO identity of the object.
pc - The object that is hollow that we are going to manage

newObjectProviderForHollowPopulated

ObjectProvider newObjectProviderForHollowPopulated(Class pcClass,
                                                   Object id,
                                                   FieldValues fv)
Constructs an ObjectProvider to manage a recently populated hollow instance having the given object ID and the given field values. This constructor is used for creating new instances of persistent objects obtained e.g. via a Query or backed by a view.

Parameters:
pcClass - the class of the new instance to be created.
id - the JDO identity of the object.
fv - the initial field values of the object.

newObjectProviderForPersistentClean

ObjectProvider newObjectProviderForPersistentClean(Object id,
                                                   Object pc)
Constructs an ObjectProvider to manage the specified persistent instance having the given object ID.

Parameters:
id - the JDO identity of the object.
pc - The object that is persistent that we are going to manage

newObjectProviderForHollowPopulatedAppId

ObjectProvider newObjectProviderForHollowPopulatedAppId(Class pcClass,
                                                        FieldValues fv)
Deprecated. Use newForHollowPopulated instead

Constructs an ObjectProvider to manage a hollow (or pclean) instance having the given FieldValues. This constructor is used for creating new instances of existing persistent objects using application identity.

Parameters:
pcClass - the class of the new instance to be created.
fv - the initial field values of the object.

newObjectProviderForEmbedded

ObjectProvider newObjectProviderForEmbedded(Object pc,
                                            boolean copyPc,
                                            ObjectProvider ownerOP,
                                            int ownerFieldNumber)
Constructs an ObjectProvider to manage a persistable instance that will be EMBEDDED/SERIALISED into another persistable object. The instance will not be assigned an identity in the process since it is a SCO.

Parameters:
pc - The persistable to manage (see copyPc also)
copyPc - Whether the SM should manage a copy of the passed PC or that one
ownerOP - Owner ObjectProvider
ownerFieldNumber - Field number in owner object where this is stored

newObjectProviderForEmbedded

ObjectProvider newObjectProviderForEmbedded(AbstractClassMetaData cmd,
                                            ObjectProvider ownerOP,
                                            int ownerFieldNumber)
Constructs an ObjectProvider for an object of the specified type, creating the PC object to hold the values where this object will be EMBEDDED/SERIALISED into another persistable object. The instance will not be assigned an identity in the process since it is a SCO.

Parameters:
cmd - Meta-data for the class that this is an instance of.
ownerOP - Owner ObjectProvider
ownerFieldNumber - Field number in owner object where this is stored

newObjectProviderForPersistentNew

ObjectProvider newObjectProviderForPersistentNew(Object pc,
                                                 FieldValues fv)
Constructs an ObjectProvider to manage a transient instance that is becoming newly persistent. A new object ID for the instance is obtained from the store manager and the object is inserted in the data store. This constructor is used for assigning state managers to existing instances that are transitioning to a persistent state.

Parameters:
pc - the instance being make persistent.
fv - Any changes to make before inserting

newObjectProviderForTransactionalTransient

ObjectProvider newObjectProviderForTransactionalTransient(Object pc)
Constructs an ObjectProvider to manage a Transactional Transient instance. A new object ID for the instance is obtained from the store manager and the object is inserted in the data store. This constructor is used for assigning state managers to Transient instances that are transitioning to a transient clean state.

Parameters:
pc - the instance being make persistent.

newObjectProviderForDetached

ObjectProvider newObjectProviderForDetached(Object pc,
                                            Object id,
                                            Object version)
Constructor for creating ObjectProvider instances to manage persistable objects in detached state.

Parameters:
pc - the detached object
id - the JDO identity of the object.
version - the detached version

newObjectProviderForPNewToBeDeleted

ObjectProvider newObjectProviderForPNewToBeDeleted(Object pc)
Constructor for creating ObjectProvider instances to manage persistable objects that are not persistent yet are about to be deleted. Consequently the initial lifecycle state will be P_NEW, but will soon move to P_NEW_DELETED.

Parameters:
pc - the object being deleted from persistence

addObjectProvider

void addObjectProvider(ObjectProvider op)
Method to add the object managed by the specified ObjectProvider to the cache.

Parameters:
op - The ObjectProvider

removeObjectProvider

void removeObjectProvider(ObjectProvider op)
Method to remove the object managed by the specified ObjectProvider from the cache.

Parameters:
op - The ObjectProvider

evictObject

void evictObject(Object pc)
Method to evict the passed object.

Parameters:
pc - The object

evictObjects

void 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

evictAllObjects

void evictAllObjects()
Method to evict all L1 cache objects


retrieveObject

void retrieveObject(Object pc,
                    boolean fgOnly)
Method to retrieve the passed object.

Parameters:
pc - The object
fgOnly - Just retrieve the current fetch group

persistObject

Object persistObject(Object pc,
                     boolean merging)
Method to persist the passed object.

Parameters:
pc - The object
merging - Whether this object (and dependents) is being merged
Returns:
The persisted object

persistObjects

Object[] persistObjects(Object[] pcs)
Method to persist the passed object(s).

Parameters:
pcs - The objects to persist
Returns:
The persisted objects

persistObjectInternal

Object persistObjectInternal(Object pc,
                             FieldValues preInsertChanges,
                             ObjectProvider ownerOP,
                             int ownerFieldNum,
                             int objectType)
Method to persist the passed object (internally).

Parameters:
pc - The object
preInsertChanges - Changes to be made before inserting
ownerOP - ObjectProvider of the owner when embedded
ownerFieldNum - Field number in the owner where this is embedded (or -1 if not embedded)
objectType - Type of object (see org.datanucleus.store.ObjectProvider, e.g ObjectProvider.PC)
Returns:
The persisted object

persistObjectInternal

Object persistObjectInternal(Object pc,
                             ObjectProvider ownerOP,
                             int ownerFieldNum,
                             int objectType)
Method to persist the passed object (internally).

Parameters:
pc - The object
ownerOP - ObjectProvider of the owner when embedded
ownerFieldNum - Field number in the owner where this is embedded (or -1 if not embedded)
objectType - Type of object (see org.datanucleus.StateManager, e.g StateManager.PC)
Returns:
The persisted object

persistObjectInternal

Object persistObjectInternal(Object pc,
                             FieldValues preInsertChanges,
                             int objectType)
Method to persist the passed object (internally).

Parameters:
pc - The object
preInsertChanges - Changes to be made before inserting
objectType - Type of object (see org.datanucleus.StateManager, e.g StateManager.PC)
Returns:
The persisted object

makeObjectTransient

void 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

makeObjectTransactional

void makeObjectTransactional(Object pc)
Method to make the passed object transactional.

Parameters:
pc - The object

makeObjectNontransactional

void makeObjectNontransactional(Object pc)
Method to make the passed object nontransactional.

Parameters:
pc - The object

exists

boolean exists(Object obj)
Method to return if the specified object exists in the datastore.

Parameters:
obj - The (persistable) object
Returns:
Whether it exists

getManagedObjects

Set 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

getManagedObjects

Set 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

getManagedObjects

Set 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

getManagedObjects

Set 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

deleteObject

void deleteObject(Object obj)
Method to delete an object from the datastore.

Parameters:
obj - The object

deleteObjects

void deleteObjects(Object[] objs)
Method to delete an array of objects from the datastore.

Parameters:
objs - The objects to delete

deleteObjectInternal

void deleteObjectInternal(Object pc)
Method to delete the passed object (internally).

Parameters:
pc - The object

detachObject

void detachObject(Object pc,
                  FetchPlanState state)
Method to detach the passed object.

Parameters:
pc - The object to detach
state - State for the detachment process.

detachObjectCopy

Object detachObjectCopy(Object pc,
                        FetchPlanState state)
Method to detach a copy of the passed object using the provided state.

Parameters:
pc - The object
state - State for the detachment process
Returns:
The detached copy of the object

detachAll

void detachAll()
Method to detach all managed objects.


attachObject

void attachObject(ObjectProvider op,
                  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:
op - ObjectProvider 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

Object attachObjectCopy(ObjectProvider op,
                        Object pc,
                        boolean sco)
Method to attach a copy of the passed object (and related objects).

Parameters:
op - ObjectProvider 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

getAttachedObjectForId

Object 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

refreshObject

void refreshObject(Object pc)
Method to refresh the passed object.

Parameters:
pc - The object

refreshAllObjects

void refreshAllObjects()
Method to refresh all L1 cache objects


enlistInTransaction

void enlistInTransaction(ObjectProvider op)
Method to enlist the specified ObjectProvider in the current transaction.

Parameters:
op - The ObjectProvider

isEnlistedInTransaction

boolean 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

evictFromTransaction

void evictFromTransaction(ObjectProvider op)
Method to evict the specified ObjectProvider from the current transaction.

Parameters:
op - The ObjectProvider

markDirty

void markDirty(ObjectProvider op,
               boolean directUpdate)
Mark the specified ObjectProvider as dirty

Parameters:
op - ObjectProvider
directUpdate - Whether the object has had a direct update made on it (if known)

clearDirty

void clearDirty(ObjectProvider op)
Mark the specified ObjectProvider as clean.

Parameters:
op - The ObjectProvider

clearDirty

void clearDirty()
Method to mark as clean all ObjectProviders of dirty objects.


isDelayDatastoreOperationsEnabled

boolean 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

processNontransactionalUpdate

void 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

Object 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

findObject

Object 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

findObjects

Object[] findObjects(Object[] ids,
                     boolean validate)
Accessor for objects with the specified identities.

Parameters:
ids - Ids of the object(s).
validate - Whether to validate the object state
Returns:
The Objects with these ids (same order)
Throws:
NucleusObjectNotFoundException - if an object doesn't exist in the datastore

getExtent

Extent getExtent(Class candidateClass,
                 boolean includeSubclasses)
Accessor for the Extent for a class (and optionally its subclasses).

Parameters:
candidateClass - The class
includeSubclasses - Whether to include subclasses
Returns:
The Extent

newQuery

Query newQuery()
Accessor for a new Query.

Returns:
The new Query

putObjectIntoLevel1Cache

void putObjectIntoLevel1Cache(ObjectProvider op)
Method to put a Persistable object associated to the ObjectProvider into the L1 cache.

Parameters:
op - The ObjectProvider

getObjectFromCache

Object getObjectFromCache(Object id)
Convenience method to access an object in the cache. Firstly looks in the L1 cache for this PM, and if not found looks in the L2 cache.

Parameters:
id - Id of the object
Returns:
Persistable object (with connected StateManager).

removeObjectFromLevel1Cache

void removeObjectFromLevel1Cache(Object id)
Method to remove an object from the L1 cache.

Parameters:
id - The id of the object

removeObjectFromLevel2Cache

void removeObjectFromLevel2Cache(Object id)
Method to remove an object from the L2 cache.

Parameters:
id - The id of the object

hasIdentityInCache

boolean 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

newObjectId

Object newObjectId(Class pcClass,
                   Object key)
This method returns an object id instance corresponding to the pcClass and key arguments. Operates in 2 modes :-

Parameters:
pcClass - Class of the PersistenceCapable to create the identity for
key - Value of the key for SingleFieldIdentity (or the toString value)
Returns:
The new object-id instance

newObjectId

Object 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.

getSerializeReadForClass

boolean 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

assertClassPersistable

void 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

hasPersistenceInformationForClass

boolean 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

isInserting

boolean 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.

isFlushing

boolean isFlushing()
Accessor for whether the ObjectManager is flushing changes to the datastore.

Returns:
Whether it is currently flushing

isRunningDetachAllOnCommit

boolean isRunningDetachAllOnCommit()
Accessor for whether this ObjectManager is currently running detachAllOnCommit.

Returns:
Whether running detachAllOnCommit

flush

void 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.


flushInternal

void 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

getMultithreaded

boolean getMultithreaded()
Accessor for whether this context is multithreaded.

Returns:
Whether multithreaded (and hence needing locking)

getManageRelations

boolean getManageRelations()
Whether managed relations are supported by this execution context.

Returns:
Supporting managed relations

getRelationshipManager

RelationshipManager getRelationshipManager(ObjectProvider op)
Accessor for the RelationshipManager for the provided ObjectProvider.

Parameters:
op - ObjectProvider
Returns:
The RelationshipManager

isManagingRelations

boolean isManagingRelations()
Returns whether this ObjectManager is currently performing the manage relationships task.

Returns:
Whether in the process of managing relations

getObjectsToBeFlushed

List<ObjectProvider> getObjectsToBeFlushed()
Convenience method to inspect the list of objects with outstanding changes to flush.

Returns:
ObjectProviders for the objects to be flushed.

getCallbackHandler

CallbackHandler getCallbackHandler()
Retrieve the callback handler for this PM

Returns:
the callback handler

addListener

void addListener(Object listener,
                 Class[] classes)
Method to register a listener for instances of the specified classes.

Parameters:
listener - The listener to sends events to
classes - The classes that it is interested in

removeListener

void removeListener(Object listener)
Method to remove a currently registered listener.

Parameters:
listener - The instance lifecycle listener to remove.

disconnectLifecycleListener

void disconnectLifecycleListener()
Disconnect the registered LifecycleListener


getInternalFetchGroup

FetchGroup 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

addInternalFetchGroup

void addInternalFetchGroup(FetchGroup grp)
Method to add an internal fetch group to this ObjectManager.

Parameters:
grp - The internal fetch group

getFetchGroupsWithName

Set getFetchGroupsWithName(String name)
Accessor for the fetch groups for the specified name.

Parameters:
name - Name of the group
Returns:
The FetchGroup

getLock

Lock getLock()
Accessor for the lock object for this ObjectManager.

Returns:
The lock object

newInstance

Object newInstance(Class cls)
Method to generate an instance of an interface, abstract class, or concrete PC class.

Parameters:
cls - The class of the interface or abstract class, or concrete class defined in MetaData
Returns:
The instance of this type

isObjectModifiedInTransaction

boolean 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

replaceObjectId

void replaceObjectId(Object 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


Copyright © 2012. All Rights Reserved.