org.datanucleus.state
Interface StateManager

All Superinterfaces:
ObjectProvider
All Known Implementing Classes:
AbstractStateManager, JDOStateManager

public interface StateManager
extends ObjectProvider

StateManager for a persistable object. Based around the JDO PersistenceCapable contract. Makes the assumption that a StateManager corresponds to ONE persistable object.


Field Summary
 
Fields inherited from interface org.datanucleus.state.ObjectProvider
EMBEDDED_COLLECTION_ELEMENT_PC, EMBEDDED_MAP_KEY_PC, EMBEDDED_MAP_VALUE_PC, EMBEDDED_PC, ORIGINAL_FIELD_VALUE_KEY_PREFIX, PC
 
Method Summary
 void checkInheritance(FieldValues fv)
          Look to the database to determine which class this object is.
 void initialiseForCachedPC(CachedPC cachedPC, Object id)
          Initialise the ObjectProvider, assigning the specified id to the object.
 void initialiseForDetached(Object pc, Object id, Object version)
          Initialises the ObjectProvider to manage a persistable object in detached state.
 void initialiseForEmbedded(Object pc, boolean copyPc)
          Initialises a state manager to manage a PersistenceCapable instance that will be EMBEDDED/SERIALISED into another PersistenceCapable object.
 void initialiseForHollow(Object id, FieldValues fv, Class pcClass)
          Initialises a state manager to manage a hollow instance having the given object ID and the given (optional) field values.
 void initialiseForHollowAppId(FieldValues fv, Class pcClass)
          Initialises a state manager to manage a HOLLOW / P_CLEAN instance having the given FieldValues.
 void initialiseForHollowPreConstructed(Object id, Object pc)
          Initialises a state manager to manage the given hollow instance having the given object ID.
 void initialiseForPersistentClean(Object id, Object pc)
          Initialises a state manager to manage the passed persistent instance having the given object ID.
 void initialiseForPersistentNew(Object pc, FieldValues preInsertChanges)
          Initialises a state manager to manage a transient instance that is becoming newly persistent.
 void initialiseForPNewToBeDeleted(Object pc)
          Initialises the StateManager to manage a PersistenceCapable object that is not persistent but that is about to be deleted.
 void initialiseForTransactionalTransient(Object pc)
          Initialises a state manager to manage a Transactional Transient instance.
 
Methods inherited from interface org.datanucleus.state.ObjectProvider
addEmbeddedOwner, attach, attach, attachCopy, becomingDeleted, changeActivityState, clearFields, clearLoadedFlags, clearNonPrimaryKeyFields, clearSavedFields, copyFieldsFromObject, deletePersistent, detach, detachCopy, disconnect, enlistInTransaction, evict, evictFromTransaction, flush, getAllFieldsLoaded, getAssociatedValue, getClassMetaData, getDirtyFieldNames, getDirtyFieldNumbers, getDirtyFields, getEmbeddedOwners, getExecutionContext, getExternalObjectId, getInternalObjectId, getLifecycleState, getLoadedFieldNames, getLoadedFieldNumbers, getLoadedFields, getLockMode, getObject, getObjectAsPrintable, getReferencedPC, getTransactionalVersion, getVersion, isDeleting, isEmbedded, isFieldLoaded, isFlushedNew, isFlushedToDatastore, isInserting, isLoaded, isRestoreValues, isWaitingToBeFlushedToDatastore, loadField, loadFieldFromDatastore, loadFieldsInFetchPlan, loadFieldValues, loadUnloadedFields, loadUnloadedFieldsInFetchPlan, loadUnloadedFieldsOfClassInFetchPlan, locate, lock, makeDirty, makeNontransactional, makePersistent, makePersistentTransactionalTransient, makeTransactional, makeTransient, markAsFlushed, markForInheritanceValidation, nullifyFields, postCommit, preBegin, preRollback, provideField, provideFields, refresh, refreshFieldsInFetchPlan, refreshLoadedFields, registerTransactional, replaceAllLoadedSCOFieldsWithValues, replaceAllLoadedSCOFieldsWithWrappers, replaceField, replaceFieldMakeDirty, replaceFields, replaceFields, replaceFieldValue, replaceManagedPC, replaceNonLoadedFields, resetDetachState, restoreFields, retrieve, retrieveDetachState, runReachability, saveFields, setAssociatedValue, setFlushedNew, setFlushing, setPcObjectType, setPostStoreNewObjectId, setStoringPC, setTransactionalVersion, setVersion, unloadField, unloadNonFetchPlanFields, unlock, unsetStoringPC, unwrapSCOField, updateFieldAfterInsert, validate, wrapSCOField
 

Method Detail

initialiseForHollow

void initialiseForHollow(Object id,
                         FieldValues fv,
                         Class pcClass)
Initialises a state manager to manage a hollow instance having the given object ID and the given (optional) field values. This constructor is used for creating new instances of existing persistent objects, and consequently shouldnt be used when the StoreManager controls the creation of such objects (such as in an ODBMS).

Parameters:
id - the identity of the object.
fv - the initial field values of the object (optional)
pcClass - Class of the object that this will manage the state for

initialiseForHollowAppId

void initialiseForHollowAppId(FieldValues fv,
                              Class pcClass)
Initialises a state manager to manage a HOLLOW / P_CLEAN instance having the given FieldValues. This constructor is used for creating new instances of existing persistent objects using application identity, and consequently shouldnt be used when the StoreManager controls the creation of such objects (such as in an ODBMS).

Parameters:
fv - the initial field values of the object.
pcClass - Class of the object that this will manage the state for

initialiseForHollowPreConstructed

void initialiseForHollowPreConstructed(Object id,
                                       Object pc)
Initialises a state manager to manage the given hollow instance having the given object ID. Unlike the initialiseForHollow(java.lang.Object, org.datanucleus.store.FieldValues, java.lang.Class) method, this method does not create a new instance and instead takes a pre-constructed instance.

Parameters:
id - the identity of the object.
pc - the object to be managed.

initialiseForPersistentClean

void initialiseForPersistentClean(Object id,
                                  Object pc)
Initialises a state manager to manage the passed persistent instance having the given object ID. Used where we have retrieved a PC object from a datastore directly (not field-by-field), for example on an object datastore. This initialiser will not add StateManagers to all related PCs. This must be done by any calling process. This simply adds the StateManager to the specified object and records the id, setting all fields of the object as loaded.

Parameters:
id - the identity of the object.
pc - The object to be managed

initialiseForEmbedded

void initialiseForEmbedded(Object pc,
                           boolean copyPc)
Initialises a state manager to manage a PersistenceCapable instance that will be EMBEDDED/SERIALISED into another PersistenceCapable object. The instance will not be assigned an identity in the process since it is a SCO.

Parameters:
pc - The PersistenceCapable to manage (see copyPc also)
copyPc - Whether the SM should manage a copy of the passed PC or that one

initialiseForPersistentNew

void initialiseForPersistentNew(Object pc,
                                FieldValues preInsertChanges)
Initialises a state manager 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.
preInsertChanges - Any changes to make before inserting

initialiseForTransactionalTransient

void initialiseForTransactionalTransient(Object pc)
Initialises a state manager 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.

initialiseForDetached

void initialiseForDetached(Object pc,
                           Object id,
                           Object version)
Initialises the ObjectProvider to manage a persistable object in detached state.

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

initialiseForCachedPC

void initialiseForCachedPC(CachedPC cachedPC,
                           Object id)
Initialise the ObjectProvider, assigning the specified id to the object. This is used when getting objects out of the L2 Cache, where they have no ObjectProvider assigned, and returning them as associated with a particular ExecutionContext.

Parameters:
cachedPC - Cache object for persistable object from L2 cache
id - Id to assign to the persistable object

initialiseForPNewToBeDeleted

void initialiseForPNewToBeDeleted(Object pc)
Initialises the StateManager to manage a PersistenceCapable object that is not persistent but that is about to be deleted. The initial state will be P_NEW, but when the delete call comes in will be P_NEW_DELETED. The object will not be enlisted in the transaction.

Parameters:
pc - the object to delete

checkInheritance

void checkInheritance(FieldValues fv)
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.

Parameters:
fv - the initial field values of the object.


Copyright © 2012. All Rights Reserved.