-
- Type Parameters:
T
- Type of the object being managed
- All Superinterfaces:
StateManager
- All Known Implementing Classes:
ReferentialStateManagerImpl
,StateManagerImpl
public interface DNStateManager<T> extends StateManager
StateManager for DataNucleus systems for a managed object, extending the basic enhancement contract for a StateManager. Each StateManager manages a single Persistable object. The Persistable object can be embedded/serialised into another managed Persistable object, in which case it will return true from the isEmbedded() method, and will also have ownership information obtainable via ExecutionContext.getOwnerInformationForEmbedded(sm) and ExecutionContext.getOwnerForEmbeddedStateManager(sm).
-
-
Field Summary
Fields Modifier and Type Field Description static String
MEMBER_VALUE_STORED_PREFIX
Key prefix under which we store member (identity) value when just retrieving a FK.static String
ORIGINAL_FIELD_VALUE_KEY_PREFIX
Key prefix under which the original value of a field is stored in the entity (NonDurable objects).
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
attach(boolean embedded)
Method to attach the object being managed.void
attach(T detachedPC)
Method to attach the provided detached object into the managed instance.T
attachCopy(T detachedPC, boolean embedded)
Method to attach to this the detached persistable instanceboolean
becomingDeleted()
Whether this object is moving to a deleted state.void
checkInheritance(FieldValues fv)
Deprecated.Dont use this, to be removedvoid
clearFields()
Method to clear all fields of the object.void
clearLoadedFlags()
Method to clear all loaded flags on the object.void
clearNonPrimaryKeyFields()
Method to clear all fields that are not part of the primary key of the object.void
clearSavedFields()
Method to clear all saved fields on the object from the saved state, e.g at commit.void
connect(ExecutionContext ec, AbstractClassMetaData cmd)
Method to (re)connect this StateManager to the specified ExecutionContext and object type.void
deletePersistent()
Method to delete the object from persistence.void
detach(FetchPlanState state)
Method to detach the managed object.T
detachCopy(FetchPlanState state)
Method to make detached copy of this instancevoid
disconnect()
Disconnect this StateManager from the ExecutionContext and persistable object.void
enlistInTransaction()
void
evict()
Method to change the object state to evicted.void
evictFromTransaction()
void
flush()
Method to flush all changes to the datastore.boolean
getAllFieldsLoaded()
Returns whether all fields are loaded.Object
getAssociatedValue(Object key)
Accessor for the value of an external field.AbstractClassMetaData
getClassMetaData()
Accessor for the ClassMetaData for this persistable object.String[]
getDirtyFieldNames()
Accessor for the names of the fields that are dirty.int[]
getDirtyFieldNumbers()
Accessor for the field numbers of all dirty fields.boolean[]
getDirtyFields()
Creates a copy of the internal dirtyFields array.ExecutionContext
getExecutionContext()
Object
getExternalObjectId()
FetchPlanForClass
getFetchPlanForClass()
Accessor for the FetchPlan for this class.Object
getInternalObjectId()
Accessor for the id of the object being managed.LifeCycleState
getLifecycleState()
Accessor for the LifeCycleState of this persistable object.String[]
getLoadedFieldNames()
Accessor for the names of the fields that are loaded.int[]
getLoadedFieldNumbers()
Accessor for the field numbers of all loaded fields.boolean[]
getLoadedFields()
T
getObject()
Accessor for the persistable object being managed.String
getObjectAsPrintable()
Returns a printable form of the managed object.T
getReferencedPC()
Accessor for the referenced PC object when we are attaching or detaching.StoreManager
getStoreManager()
Object
getTransactionalVersion()
Return the object representing the transactional version of the managed object.Object
getVersion()
Method to return the current version of the managed object.void
initialiseForCachedPC(CachedPC cachedPC, Object id)
Initialise StateManager, assigning the specified id to the object.void
initialiseForDetached(T pc, Object id, Object version)
Initialises StateManager to manage a persistable object in detached state.void
initialiseForEmbedded(T pc, boolean copyPc)
Initialises a state manager to manage a persistable instance that will be EMBEDDED/SERIALISED into another persistable object.void
initialiseForHollow(Object id, FieldValues fv, Class<T> 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<T> pcClass)
Deprecated.Remove use of this and use initialiseForHollowvoid
initialiseForHollowPreConstructed(Object id, T pc)
Initialises a state manager to manage the given hollow instance having the given object ID.void
initialiseForPersistentClean(Object id, T pc)
Initialises a state manager to manage the passed persistent instance having the given object ID.void
initialiseForPersistentNew(T pc, FieldValues preInsertChanges)
Initialises a state manager to manage a transient instance that is becoming newly persistent.void
initialiseForPNewToBeDeleted(T pc)
Initialises StateManager to manage a persistable object that is not persistent but is about to be deleted.void
initialiseForTransactionalTransient(T pc)
Initialises a state manager to manage a Transactional Transient instance.boolean
isDeleted()
Tests whether this object has been deleted.boolean
isDeleting()
Tests whether this object is being deleted.boolean
isDetaching()
Tests whether this object is in the process of being detached.boolean
isEmbedded()
Convenience accessor for whether this StateManager manages an embedded/serialised object.boolean
isFieldLoaded(int fieldNumber)
Accessor for whether a field is currently loaded.boolean
isFlushedNew()
Whether this record has been flushed to the datastore in this transaction (i.e called persist() and is in the datastore now).boolean
isFlushedToDatastore()
Accessor for whether all changes have been written to the datastore.boolean
isInserting()
Tests whether this object is being inserted.boolean
isLoaded(int absoluteFieldNumber)
boolean
isRestoreValues()
Accessor for the Restore Values flagboolean
isVersionLoaded()
Method to return if the version is loaded.boolean
isWaitingToBeFlushedToDatastore()
Tests whether this object is new yet waiting to be flushed to the datastore.void
loadField(int fieldNumber)
Convenience method to load the specified field if not loaded.void
loadFieldFromDatastore(int fieldNumber)
Convenience method to load a field from the datastore.void
loadFieldsInFetchPlan(FetchPlanState state)
Method to load all unloaded fields in the FetchPlan.void
loadFieldValues(FieldValues fv)
Convenience method to load the passed field values.void
loadUnloadedFields()
Fetch from the database all fields that are not currently loaded regardless of whether they are in the current fetch group or not.void
loadUnloadedFieldsInFetchPlan()
Loads (from the database) all unloaded fields that are in the current FetchPlan.void
loadUnloadedFieldsOfClassInFetchPlan(FetchPlan fetchPlan)
Loads (from the database) all unloaded fields of the managed class that are in the specified FetchPlan.void
loadUnloadedRelationFields()
Loads (from the database) all unloaded fields that store relations.void
locate()
Method to locate that the object exists in the datastore.void
makeDirty(int field)
Marks the given field dirty.void
makeNontransactional()
Method to make the managed object nontransactional.void
makePersistent()
Method to make the managed object persistent.void
makePersistentTransactionalTransient()
Method to make Transactional Transient instances persistentvoid
makeTransactional()
Method to make the managed object transactional.void
makeTransient(FetchPlanState state)
Method to make the managed object transient.void
makeTransientForReachability()
Make the managed object transient due to reachability (at commit) finding it not needing to be persisted.void
markAsFlushed()
Method to notify the StateManager that the object has now been flushed to the datastore.void
markFieldsAsLoaded(int[] fieldNumbers)
Convenience method to mark all fields as "loaded".void
markForInheritanceValidation()
Mark the state manager as needing to validate the inheritance of the managed object existence before loading fields.void
postCommit(Transaction tx)
Convenience interceptor to allow operations to be performed after the commit is performed but before returning control to the application.void
preBegin(Transaction tx)
Convenience interceptor to allow operations to be performed before the begin is performed.void
preRollback(Transaction tx)
Convenience interceptor to allow operations to be performed before any rollback is performed.Object
provideField(int fieldNumber)
Method to return the current value of the specified field.void
provideFields(int[] fieldNumbers, FieldManager fm)
Method to obtain updated field values from the passed FieldManager.void
refresh()
Method to refresh the values of the currently loaded fields in the managed object.void
refreshFieldsInFetchPlan()
Refreshes from the database all fields in fetch plan.void
refreshLoadedFields()
Refreshes from the database all fields currently loaded.void
registerTransactional()
Registers the pc class in the cachevoid
removeAssociatedValue(Object key)
Method to remove the associated value with the specified key (if it exists).void
replaceAllLoadedSCOFieldsWithValues()
Method to replace all loaded (wrapped) SCO fields with unwrapped values.void
replaceAllLoadedSCOFieldsWithWrappers()
Method to replace all loaded SCO fields with wrappers.void
replaceField(int fieldNumber, Object value)
Method to change the value of the specified field.void
replaceFieldMakeDirty(int fieldNumber, Object value)
Method to change the value of the specified field.void
replaceFields(int[] fieldNumbers, FieldManager fm)
Method to update the data in the object with the values from the passed FieldManager.void
replaceFields(int[] fieldNumbers, FieldManager fm, boolean replaceWhenDirty)
Method to update the data in the object with the values from the passed FieldManager.void
replaceFieldValue(int fieldNumber, Object newValue)
Convenience method to change the value of a field that is assumed loaded.void
replaceManagedPC(T pc)
Method to swap the managed object for the supplied object.void
replaceNonLoadedFields(int[] fieldNumbers, FieldManager fm)
Method to update the data in the object with the values from the passed FieldManager.void
resetDetachState()
Convenience method to reset the detached state in the current object.void
restoreFields()
Method to restore all fields of the object from the saved state, in the case of rollback.void
retrieve(boolean fgOnly)
Method to retrieve the fields for this object.void
retrieveDetachState(DNStateManager sm)
Convenience method to retrieve the detach state from the passed StateManager's managed objectvoid
saveFields()
Method to save all fields of the object to a saved state, in case of later rollback.void
setAssociatedValue(Object key, Object value)
Method to set an associated value stored with this object.void
setFlushedNew(boolean flag)
void
setFlushing(boolean flushing)
void
setInserting()
void
setInsertingCallbacks()
void
setPostStoreNewObjectId(Object id)
Method to allow the setting of the id of the PC object.void
setStoringPC()
Method to set the storing PC flag.void
setTransactionalVersion(Object nextVersion)
Sets the value for the version column in a transaction not yet committedvoid
setVersion(Object version)
Method to set the current version of the managed object.void
unloadField(String fieldName)
Mark the specified field as not loaded so that it will be reloaded on next access.void
unloadNonFetchPlanFields()
Method that will unload all fields that are not in the FetchPlan.void
unsetStoringPC()
Method to unset the storing PC flag.void
updateFieldAfterInsert(Object pc, int fieldNumber)
Marks the given field dirty for issuing an update after the insert.void
updateOwnerFieldInEmbeddedField(int fieldNumber, Object value)
Method to update the owner field in an embedded field.void
validate()
Validates whether the persistence capable instance exists in the datastore.-
Methods inherited from interface org.datanucleus.enhancement.StateManager
getBooleanField, getByteField, getCharField, getDoubleField, getExecutionContextReference, getFloatField, getIntField, getLongField, getObjectField, getObjectId, getShortField, getStringField, getTransactionalObjectId, getVersion, isDeleted, isDirty, isLoaded, isNew, isPersistent, isTransactional, makeDirty, preSerialize, providedBooleanField, providedByteField, providedCharField, providedDoubleField, providedFloatField, providedIntField, providedLongField, providedObjectField, providedShortField, providedStringField, replacingBooleanField, replacingByteField, replacingCharField, replacingDetachedState, replacingDoubleField, replacingFlags, replacingFloatField, replacingIntField, replacingLongField, replacingObjectField, replacingShortField, replacingStateManager, replacingStringField, setBooleanField, setByteField, setCharField, setDoubleField, setFloatField, setIntField, setLongField, setObjectField, setShortField, setStringField
-
-
-
-
Field Detail
-
ORIGINAL_FIELD_VALUE_KEY_PREFIX
static final String ORIGINAL_FIELD_VALUE_KEY_PREFIX
Key prefix under which the original value of a field is stored in the entity (NonDurable objects). Set if a member is updated using a setter.- See Also:
- Constant Field Values
-
MEMBER_VALUE_STORED_PREFIX
static final String MEMBER_VALUE_STORED_PREFIX
Key prefix under which we store member (identity) value when just retrieving a FK. Member number is then appended to this prefix.- See Also:
- Constant Field Values
-
-
Method Detail
-
connect
void connect(ExecutionContext ec, AbstractClassMetaData cmd)
Method to (re)connect this StateManager to the specified ExecutionContext and object type.- Parameters:
ec
- ExecutionContext to connect tocmd
- Metadata for the persistable class
-
disconnect
void disconnect()
Disconnect this StateManager from the ExecutionContext and persistable object.
-
initialiseForHollow
void initialiseForHollow(Object id, FieldValues fv, Class<T> 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 shouldn't be used when the StoreManager controls the creation of such objects (such as in an ODBMS).- Parameters:
id
- the JDO 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<T> pcClass)
Deprecated.Remove use of this and use initialiseForHollowInitialises 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 shouldn't 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, T pc)
Initialises a state manager to manage the given hollow instance having the given object ID. Unlike theinitialiseForHollow(java.lang.Object, org.datanucleus.store.FieldValues, java.lang.Class<T>)
method, this method does not create a new instance and instead takes a pre-constructed instance (such as from an ODBMS).- Parameters:
id
- the identity of the object.pc
- the object to be managed.
-
initialiseForPersistentClean
void initialiseForPersistentClean(Object id, T 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 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(T pc, boolean copyPc)
Initialises a state manager 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 StateManager should manage a copy of the passed PC or that one
-
initialiseForPersistentNew
void initialiseForPersistentNew(T 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(T 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(T pc, Object id, Object version)
Initialises StateManager to manage a persistable object in detached state.- Parameters:
pc
- the detach object.id
- the identity of the object.version
- the detached version
-
initialiseForPNewToBeDeleted
void initialiseForPNewToBeDeleted(T pc)
Initialises StateManager to manage a persistable object that is not persistent but is about to be deleted.- Parameters:
pc
- the object to delete
-
initialiseForCachedPC
void initialiseForCachedPC(CachedPC cachedPC, Object id)
Initialise StateManager, assigning the specified id to the object. This is used when getting objects out of the L2 Cache, where they have no StateManager assigned, and returning them as associated with a particular ExecutionContext.- Parameters:
cachedPC
- The cached PC objectid
- Id to assign to the persistable object
-
getClassMetaData
AbstractClassMetaData getClassMetaData()
Accessor for the ClassMetaData for this persistable object.- Returns:
- The ClassMetaData.
-
getExecutionContext
ExecutionContext getExecutionContext()
-
getStoreManager
StoreManager getStoreManager()
-
getFetchPlanForClass
FetchPlanForClass getFetchPlanForClass()
Accessor for the FetchPlan for this class.- Returns:
- The FetchPlanForClass to be used on all fetches
-
getObject
T getObject()
Accessor for the persistable object being managed.- Returns:
- the persistable object
-
getObjectAsPrintable
String getObjectAsPrintable()
Returns a printable form of the managed object.- Returns:
- The object reference for the persistable object.
-
getInternalObjectId
Object getInternalObjectId()
Accessor for the id of the object being managed.- Returns:
- The identity of the object
-
getExternalObjectId
Object getExternalObjectId()
-
getLifecycleState
LifeCycleState getLifecycleState()
Accessor for the LifeCycleState of this persistable object.- Returns:
- the LifeCycleState
-
replaceField
void replaceField(int fieldNumber, Object value)
Method to change the value of the specified field. This WILL NOT make the field dirty.- Parameters:
fieldNumber
- (absolute) field number of the fieldvalue
- The new value.
-
replaceFieldMakeDirty
void replaceFieldMakeDirty(int fieldNumber, Object value)
Method to change the value of the specified field. This WILL make the field dirty.- Parameters:
fieldNumber
- (absolute) field number of the fieldvalue
- The new value.
-
replaceFieldValue
void replaceFieldValue(int fieldNumber, Object newValue)
Convenience method to change the value of a field that is assumed loaded. Will mark the object/field as dirty if it isn't previously. Only for use in management of relations.- Parameters:
fieldNumber
- Number of fieldnewValue
- The new value
-
replaceFields
void replaceFields(int[] fieldNumbers, FieldManager fm)
Method to update the data in the object with the values from the passed FieldManager.- Parameters:
fieldNumbers
- (absolute) field numbers of the fields to updatefm
- The FieldManager
-
replaceFields
void replaceFields(int[] fieldNumbers, FieldManager fm, boolean replaceWhenDirty)
Method to update the data in the object with the values from the passed FieldManager.- Parameters:
fieldNumbers
- (absolute) field numbers of the fields to updatefm
- The FieldManagerreplaceWhenDirty
- Whether to replace these fields if the field is dirty
-
replaceNonLoadedFields
void replaceNonLoadedFields(int[] fieldNumbers, FieldManager fm)
Method to update the data in the object with the values from the passed FieldManager. Only non loaded fields are updated.- Parameters:
fieldNumbers
- (absolute) field numbers of the fields to updatefm
- The FieldManager
-
replaceAllLoadedSCOFieldsWithWrappers
void replaceAllLoadedSCOFieldsWithWrappers()
Method to replace all loaded SCO fields with wrappers. If the loaded field already uses a SCO wrapper nothing happens to that field.
-
replaceAllLoadedSCOFieldsWithValues
void replaceAllLoadedSCOFieldsWithValues()
Method to replace all loaded (wrapped) SCO fields with unwrapped values. If the loaded field doesnt use a SCO wrapper nothing happens to that field.
-
provideFields
void provideFields(int[] fieldNumbers, FieldManager fm)
Method to obtain updated field values from the passed FieldManager.- Parameters:
fieldNumbers
- The numbers of the fieldsfm
- The fieldManager
-
provideField
Object provideField(int fieldNumber)
Method to return the current value of the specified field.- Parameters:
fieldNumber
- (absolute) field number of the field- Returns:
- The current value
-
setAssociatedValue
void setAssociatedValue(Object key, Object value)
Method to set an associated value stored with this object. This is for a situation such as in ORM where this object can have an "external" foreign-key provided by an owning object (e.g 1-N uni relation and this is the element with no knowledge of the owner, so the associated value is the FK value).- Parameters:
key
- Key for the valuevalue
- The associated value
-
getAssociatedValue
Object getAssociatedValue(Object key)
Accessor for the value of an external field. This is for a situation such as in ORM where this object can have an "external" foreign-key provided by an owning object (e.g 1-N uni relation and this is the element with no knowledge of the owner, so the associated value is the FK value).- Parameters:
key
- The key for this associated information- Returns:
- The value stored (if any) against this key
-
removeAssociatedValue
void removeAssociatedValue(Object key)
Method to remove the associated value with the specified key (if it exists).- Parameters:
key
- The key
-
getDirtyFieldNumbers
int[] getDirtyFieldNumbers()
Accessor for the field numbers of all dirty fields.- Returns:
- Absolute field numbers of the dirty fields in this instance.
-
getDirtyFieldNames
String[] getDirtyFieldNames()
Accessor for the names of the fields that are dirty.- Returns:
- Names of the dirty fields
-
getDirtyFields
boolean[] getDirtyFields()
Creates a copy of the internal dirtyFields array.- Returns:
- a copy of the internal dirtyFields array.
-
makeDirty
void makeDirty(int field)
Marks the given field dirty.- Parameters:
field
- The no of field to mark as dirty.
-
isEmbedded
boolean isEmbedded()
Convenience accessor for whether this StateManager manages an embedded/serialised object.- Returns:
- Whether the managed object is embedded/serialised.
-
updateOwnerFieldInEmbeddedField
void updateOwnerFieldInEmbeddedField(int fieldNumber, Object value)
Method to update the owner field in an embedded field.- Parameters:
fieldNumber
- The field of this object that is embeddedvalue
- The value of the field (embedded)
-
setStoringPC
void setStoringPC()
Method to set the storing PC flag.
-
unsetStoringPC
void unsetStoringPC()
Method to unset the storing PC flag.
-
setInserting
void setInserting()
-
setInsertingCallbacks
void setInsertingCallbacks()
-
isFlushedToDatastore
boolean isFlushedToDatastore()
Accessor for whether all changes have been written to the datastore.- Returns:
- Whether the datastore has all changes
-
isFlushedNew
boolean isFlushedNew()
Whether this record has been flushed to the datastore in this transaction (i.e called persist() and is in the datastore now). If user has called persist() on it yet not yet persisted then returns false.- Returns:
- Whether this is flushed new.
-
setFlushedNew
void setFlushedNew(boolean flag)
-
flush
void flush()
Method to flush all changes to the datastore.
-
setFlushing
void setFlushing(boolean flushing)
-
markAsFlushed
void markAsFlushed()
Method to notify the StateManager that the object has now been flushed to the datastore. This is performed when handling inserts or deletes in a batch external to StateManager.
-
locate
void locate()
Method to locate that the object exists in the datastore.- Throws:
NucleusObjectNotFoundException
- if not present
-
isWaitingToBeFlushedToDatastore
boolean isWaitingToBeFlushedToDatastore()
Tests whether this object is new yet waiting to be flushed to the datastore.- Returns:
- true if this instance is waiting to be flushed
-
isInserting
boolean isInserting()
Tests whether this object is being inserted.- Returns:
- true if this instance is inserting.
-
isDeleting
boolean isDeleting()
Tests whether this object is being deleted.- Returns:
- true if this instance is being deleted.
-
becomingDeleted
boolean becomingDeleted()
Whether this object is moving to a deleted state.- Returns:
- Whether the object will be moved into a deleted state during this operation
-
isDeleted
boolean isDeleted()
Tests whether this object has been deleted. Instances that have been deleted in the current transaction return true. Transient instances return false.- Returns:
- true if this instance was deleted in the current transaction.
-
isDetaching
boolean isDetaching()
Tests whether this object is in the process of being detached.- Returns:
- true if this instance is being detached.
-
loadFieldValues
void loadFieldValues(FieldValues fv)
Convenience method to load the passed field values. Loads the fields using any required fetch plan and calls postLoad as appropriate.- Parameters:
fv
- Field Values to load (including any fetch plan to use when loading)
-
getReferencedPC
T getReferencedPC()
Accessor for the referenced PC object when we are attaching or detaching. 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.- Returns:
- The referenced object (or null).
-
loadField
void loadField(int fieldNumber)
Convenience method to load the specified field if not loaded.- Parameters:
fieldNumber
- Absolute field number
-
loadFieldsInFetchPlan
void loadFieldsInFetchPlan(FetchPlanState state)
Method to load all unloaded fields in the FetchPlan. Recurses through the FetchPlan objects and loads fields of sub-objects where needed.- Parameters:
state
- The FetchPlan state
-
loadFieldFromDatastore
void loadFieldFromDatastore(int fieldNumber)
Convenience method to load a field from the datastore. Used in attaching fields and checking their old values (so we don't want any postLoad method being called). TODO Merge this with one of the loadXXXFields methods.- Parameters:
fieldNumber
- The field number.
-
loadUnloadedFieldsInFetchPlan
void loadUnloadedFieldsInFetchPlan()
Loads (from the database) all unloaded fields that are in the current FetchPlan.
-
loadUnloadedFieldsOfClassInFetchPlan
void loadUnloadedFieldsOfClassInFetchPlan(FetchPlan fetchPlan)
Loads (from the database) all unloaded fields of the managed class that are in the specified FetchPlan.- Parameters:
fetchPlan
- The FetchPlan
-
loadUnloadedRelationFields
void loadUnloadedRelationFields()
Loads (from the database) all unloaded fields that store relations.
-
loadUnloadedFields
void loadUnloadedFields()
Fetch from the database all fields that are not currently loaded regardless of whether they are in the current fetch group or not. Called by lifecycle transitions.
-
unloadNonFetchPlanFields
void unloadNonFetchPlanFields()
Method that will unload all fields that are not in the FetchPlan.
-
refreshLoadedFields
void refreshLoadedFields()
Refreshes from the database all fields currently loaded. Called by life-cycle transitions.
-
refreshFieldsInFetchPlan
void refreshFieldsInFetchPlan()
Refreshes from the database all fields in fetch plan. Called by life-cycle transitions.
-
clearNonPrimaryKeyFields
void clearNonPrimaryKeyFields()
Method to clear all fields that are not part of the primary key of the object.
-
restoreFields
void restoreFields()
Method to restore all fields of the object from the saved state, in the case of rollback.
-
saveFields
void saveFields()
Method to save all fields of the object to a saved state, in case of later rollback.
-
clearSavedFields
void clearSavedFields()
Method to clear all saved fields on the object from the saved state, e.g at commit.
-
clearFields
void clearFields()
Method to clear all fields of the object.
-
registerTransactional
void registerTransactional()
Registers the pc class in the cache
-
isRestoreValues
boolean isRestoreValues()
Accessor for the Restore Values flag- Returns:
- Whether to restore values
-
clearLoadedFlags
void clearLoadedFlags()
Method to clear all loaded flags on the object.
-
unloadField
void unloadField(String fieldName)
Mark the specified field as not loaded so that it will be reloaded on next access.- Parameters:
fieldName
- Name of the field
-
getLoadedFields
boolean[] getLoadedFields()
-
getLoadedFieldNumbers
int[] getLoadedFieldNumbers()
Accessor for the field numbers of all loaded fields.- Returns:
- Absolute field numbers of the loaded fields in this instance.
-
getLoadedFieldNames
String[] getLoadedFieldNames()
Accessor for the names of the fields that are loaded.- Returns:
- Names of the loaded fields
-
isLoaded
boolean isLoaded(int absoluteFieldNumber)
-
getAllFieldsLoaded
boolean getAllFieldsLoaded()
Returns whether all fields are loaded.- Returns:
- Returns true if all fields are loaded.
-
isFieldLoaded
boolean isFieldLoaded(int fieldNumber)
Accessor for whether a field is currently loaded. Just returns the status, unlike "isLoaded" which also loads it if not.- Parameters:
fieldNumber
- The (absolute) field number- Returns:
- Whether it is loaded
-
updateFieldAfterInsert
void updateFieldAfterInsert(Object pc, int fieldNumber)
Marks the given field dirty for issuing an update after the insert.- Parameters:
pc
- The Persistable objectfieldNumber
- The no of field to mark as dirty.
-
setPostStoreNewObjectId
void setPostStoreNewObjectId(Object id)
Method to allow the setting of the id of the PC object. This is used when it is obtained after persisting the object to the datastore. In the case of RDBMS, this may be via auto-increment, or in the case of ODBMS this may be an accessor for the id after storing.- Parameters:
id
- the id received from the datastore. May be an OID, or the key value for an OID, or an application id.
-
replaceManagedPC
void replaceManagedPC(T pc)
Method to swap the managed object for the supplied object. This is of particular use for object datastores where the datastore is responsible for creating the in-memory object and where we have a temporary object that we want to swap for the datastore generated object. Makes no change to what fields are loaded/dirty etc, just swaps the managed object.- Parameters:
pc
- The persistable object to use
-
setTransactionalVersion
void setTransactionalVersion(Object nextVersion)
Sets the value for the version column in a transaction not yet committed- Parameters:
nextVersion
- version to use
-
getTransactionalVersion
Object getTransactionalVersion()
Return the object representing the transactional version of the managed object.- Returns:
- the object representing the version of the calling instance
-
setVersion
void setVersion(Object version)
Method to set the current version of the managed object.- Parameters:
version
- The version
-
getVersion
Object getVersion()
Method to return the current version of the managed object.- Returns:
- The version
-
isVersionLoaded
boolean isVersionLoaded()
Method to return if the version is loaded. If the class represented is not versioned then returns true.- Returns:
- Whether it is loaded.
-
evictFromTransaction
void evictFromTransaction()
-
enlistInTransaction
void enlistInTransaction()
-
makeTransactional
void makeTransactional()
Method to make the managed object transactional.
-
makeNontransactional
void makeNontransactional()
Method to make the managed object nontransactional.
-
makeTransient
void makeTransient(FetchPlanState state)
Method to make the managed object transient.- Parameters:
state
- Object containing the state of any fetch plan processing
-
makeTransientForReachability
void makeTransientForReachability()
Make the managed object transient due to reachability (at commit) finding it not needing to be persisted.
-
makePersistent
void makePersistent()
Method to make the managed object persistent.
-
makePersistentTransactionalTransient
void makePersistentTransactionalTransient()
Method to make Transactional Transient instances persistent
-
deletePersistent
void deletePersistent()
Method to delete the object from persistence.
-
attachCopy
T attachCopy(T detachedPC, boolean embedded)
Method to attach to this the detached persistable instance- Parameters:
detachedPC
- the detached persistable instance to be attachedembedded
- Whether it is embedded- Returns:
- The attached copy
-
attach
void attach(boolean embedded)
Method to attach the object being managed.- Parameters:
embedded
- Whether it is embedded
-
attach
void attach(T detachedPC)
Method to attach the provided detached object into the managed instance.- Parameters:
detachedPC
- Detached object
-
detachCopy
T detachCopy(FetchPlanState state)
Method to make detached copy of this instance- Parameters:
state
- State for the detachment process- Returns:
- the detached persistable instance
-
detach
void detach(FetchPlanState state)
Method to detach the managed object.- Parameters:
state
- State for the detachment process
-
validate
void validate()
Validates whether the persistence capable instance exists in the datastore. If the instance does not exist in the datastore, this method will fail raising a NucleusObjectNotFoundException.
-
markForInheritanceValidation
void markForInheritanceValidation()
Mark the state manager as needing to validate the inheritance of the managed object existence before loading fields.
-
evict
void evict()
Method to change the object state to evicted.
-
refresh
void refresh()
Method to refresh the values of the currently loaded fields in the managed object.
-
retrieve
void retrieve(boolean fgOnly)
Method to retrieve the fields for this object.- Parameters:
fgOnly
- Whether to retrieve just the current fetch plan fields
-
preBegin
void preBegin(Transaction tx)
Convenience interceptor to allow operations to be performed before the begin is performed.- Parameters:
tx
- The transaction
-
postCommit
void postCommit(Transaction tx)
Convenience interceptor to allow operations to be performed after the commit is performed but before returning control to the application.- Parameters:
tx
- The transaction
-
preRollback
void preRollback(Transaction tx)
Convenience interceptor to allow operations to be performed before any rollback is performed.- Parameters:
tx
- The transaction
-
resetDetachState
void resetDetachState()
Convenience method to reset the detached state in the current object.
-
retrieveDetachState
void retrieveDetachState(DNStateManager sm)
Convenience method to retrieve the detach state from the passed StateManager's managed object- Parameters:
sm
- StateManager
-
checkInheritance
void checkInheritance(FieldValues fv)
Deprecated.Dont use this, to be removedLook 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. TODO This is only called by some outdated code in LDAPUtils; remove it when that is fixed- Parameters:
fv
- the initial field values of the object.
-
markFieldsAsLoaded
void markFieldsAsLoaded(int[] fieldNumbers)
Convenience method to mark all fields as "loaded". NOTE: This is a convenience mutator only to be used when you know what you are doing. Currently only used by the XML plugin.- Parameters:
fieldNumbers
- The field numbers to mark as loaded
-
-