org.datanucleus.state
Interface ObjectProvider

All Known Implementing Classes:
AbstractStateManager, JDOStateManager

public interface ObjectProvider

Provider of field information for a managed object. A JDO StateManager is one possible implementation of an ObjectProvider, using bytecode enhancement in that case. Another possible implementation would use Java reflection to obtain and set field values in the object.


Field Summary
static short EMBEDDED_COLLECTION_ELEMENT_PC
          Embedded (or serialised) Collection Element PC
static short EMBEDDED_MAP_KEY_PC
          Embedded (or serialised) Map Key PC
static short EMBEDDED_MAP_VALUE_PC
          Embedded (or serialised) Map Value PC
static short EMBEDDED_PC
          Embedded (or serialised) PC
static String ORIGINAL_FIELD_VALUE_KEY_PREFIX
          Key prefix under which the original value of a field is stored in the entity (nondurable objects).
static short PC
          PC
 
Method Summary
 void attach(boolean embedded)
          Method to attach the object managed by this StateManager.
 void attach(Object trans)
          Method to attach the provided transient into the managed instance.
 Object attachCopy(Object detachedPC, boolean embedded)
          Method to attach to this the detached persistable instance
 boolean becomingDeleted()
          Whether this object is moving to a deleted state.
 void changeActivityState(ActivityState state)
          Update the acitvity state.
 void checkInheritance(FieldValues fv)
          Deprecated. Dont use this, to be removed
 void 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.
 void connect(ExecutionContext ec, AbstractClassMetaData cmd)
          Method to (re)connect this provider to the specified ExecutionContext and object type.
 void copyFieldsFromObject(Object pc, int[] fieldNumbers)
          Convenience method to update our object with the field values from the passed object.
 void deletePersistent()
          Method to delete the object from persistence.
 void detach(FetchPlanState state)
          Method to detach the persistable object.
 Object detachCopy(FetchPlanState state)
          Method to make detached copy of this instance
 void disconnect()
          Disconnect this provider from the ExecutionContext and PC 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 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.
 ObjectProvider[] getEmbeddedOwners()
          Accessor for the overall owner ObjectProviders of the managed object when embedded.
 ExecutionContext getExecutionContext()
           
 Object getExternalObjectId()
           
 Object getInternalObjectId()
          Accessor for the id of the object managed by this ObjectProvider.
 LifeCycleState getLifecycleState()
          Accessor for the LifeCycleState
 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()
           
 short getLockMode()
          Accessor for the current lock mode.
 Object getObject()
          The object being persisted, or a virtual object containing properties to be persisted For persistence of (depends on the API/language): - Java objects, the object returned is the actual Java object being persisted - JSON objects, the object returned is an instance of org.json.JSONObject - XML objects, the object returned is an instance of org.w3c.dom.Node Warning: to obtain the type being persisted use getClassMetaData(), otherwise the store will not be able objects from any language
 String getObjectAsPrintable()
          Returns a printable form of the managed object.
 Object getReferencedPC()
          Accessor for the referenced PC object when we are attaching or detaching.
 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 the ObjectProvider, assigning the specified id to the object.
 void initialiseForDetached(Object pc, Object id, Object version)
          Initialises the StateManager to manage a persistable object in detached state.
 void initialiseForEmbedded(Object 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 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)
          Deprecated. Remove use of this and use initialiseForHollow
 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 persistable object that is not persistent but is about to be deleted.
 void initialiseForTransactionalTransient(Object pc)
          Initialises a state manager to manage a Transactional Transient instance.
 boolean isDeleting()
          Tests whether this object is in the process of being deleted.
 boolean isEmbedded()
          Convenience accessor for whether this ObjectProvider 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 flag
 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()
          Fetchs from the database all fields that are not currently loaded and that are in the current fetch group.
 void loadUnloadedFieldsOfClassInFetchPlan(FetchPlan fetchPlan)
          Loads all unloaded fields of the managed class that are in the current FetchPlan.
 void locate()
          Method to locate that the object exists in the datastore.
 void lock(short lockMode)
          Method to lock the object owned by this ObjectProvider.
 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 persistent
 void makeTransactional()
          Method to make the managed object transactional.
 void makeTransient(FetchPlanState state)
          Method to make the managed object transient.
 void markAsFlushed()
          Method to notify the object provider that the object has now been flushed to the datastore.
 void markForInheritanceValidation()
          Mark the state manager as needing to validate the inheritance of the managed object existence before loading fields.
 void nullifyFields()
          Nullify fields with reference to persistable or SCO instances
 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 cache
 void 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(Object 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.
 void retrieve(boolean fgOnly)
          Method to retrieve the fields for this object.
 void retrieveDetachState(ObjectProvider op)
          Convenience method to retrieve the detach state from the passed ObjectProvider's object
 void runReachability(Set reachables)
          Method to run reachability from this ObjectProvider.
 void saveFields()
          Method to save all fields of the object.
 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 setPcObjectType(short type)
          Method to set this ObjectProvider as managing an embedded/serialised object.
 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 committed
 void 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 unlock()
          Method to unlock the object owned by this ObjectProvider (if locked).
 void unsetStoringPC()
          Method to unset the storing PC flag.
 Object unwrapSCOField(int fieldNumber, Object value, boolean replaceFieldIfChanged)
          Method to unwrap a SCO field (if it is wrapped currently) and return the unwrapped value.
 void updateFieldAfterInsert(Object pc, int fieldNumber)
          Marks the given field dirty for issuing an update after the insert.
 void validate()
          Validates whether the persistence capable instance exists in the datastore.
 Object wrapSCOField(int fieldNumber, Object value, boolean forInsert, boolean forUpdate, boolean replaceFieldIfChanged)
          Method to wrap a SCO field (if not wrapped currently) and return the wrapped value.
 

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). This value is set if a field is updated using a setter.

See Also:
Constant Field Values

PC

static final short PC
PC

See Also:
Constant Field Values

EMBEDDED_PC

static final short EMBEDDED_PC
Embedded (or serialised) PC

See Also:
Constant Field Values

EMBEDDED_COLLECTION_ELEMENT_PC

static final short EMBEDDED_COLLECTION_ELEMENT_PC
Embedded (or serialised) Collection Element PC

See Also:
Constant Field Values

EMBEDDED_MAP_KEY_PC

static final short EMBEDDED_MAP_KEY_PC
Embedded (or serialised) Map Key PC

See Also:
Constant Field Values

EMBEDDED_MAP_VALUE_PC

static final short EMBEDDED_MAP_VALUE_PC
Embedded (or serialised) Map Value PC

See Also:
Constant Field Values
Method Detail

connect

void connect(ExecutionContext ec,
             AbstractClassMetaData cmd)
Method to (re)connect this provider to the specified ExecutionContext and object type.


disconnect

void disconnect()
Disconnect this provider from the ExecutionContext and PC object.


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 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 pcClass)
Deprecated. Remove use of this and use initialiseForHollow

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 (such as from an ODBMS).

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

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 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(Object pc)
Initialises the 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 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 - The cached PC object
id - Id to assign to the persistable object

getClassMetaData

AbstractClassMetaData getClassMetaData()
Accessor for the ClassMetaData for this object.

Returns:
The ClassMetaData.

getExecutionContext

ExecutionContext getExecutionContext()

getObject

Object getObject()
The object being persisted, or a virtual object containing properties to be persisted For persistence of (depends on the API/language): - Java objects, the object returned is the actual Java object being persisted - JSON objects, the object returned is an instance of org.json.JSONObject - XML objects, the object returned is an instance of org.w3c.dom.Node Warning: to obtain the type being persisted use getClassMetaData(), otherwise the store will not be able objects from any language

Returns:
the object being persisted, or a virtual object containing properties to be persisted

getObjectAsPrintable

String getObjectAsPrintable()
Returns a printable form of the managed object. Typically returns Object.toString() form of the managed object.

Returns:
The printable form of the object

getInternalObjectId

Object getInternalObjectId()
Accessor for the id of the object managed by this ObjectProvider.

Returns:
The identity of the object

getExternalObjectId

Object getExternalObjectId()

getLifecycleState

LifeCycleState getLifecycleState()
Accessor for the LifeCycleState

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 field
value - 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 field
value - 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 isnt previously. Only for use in management of relations.

Parameters:
fieldNumber - Number of field
newValue - 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 update
fm - 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 update
fm - The FieldManager
replaceWhenDirty - 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 update
fm - 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 fields
fm - 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

wrapSCOField

Object wrapSCOField(int fieldNumber,
                    Object value,
                    boolean forInsert,
                    boolean forUpdate,
                    boolean replaceFieldIfChanged)
Method to wrap a SCO field (if not wrapped currently) and return the wrapped value. If the field is not a SCO field will just return the value. If "replaceFieldIfChanged" is set, we replace the value in the object with the wrapped value.

Parameters:
fieldNumber - Number of the field
value - The value to give it
forInsert - Whether the creation of any wrapper should insert this value into the datastore
forUpdate - Whether the creation of any wrapper should update the datastore with this value
replaceFieldIfChanged - Whether to replace the field in the object if wrapping the value
Returns:
The wrapper (or original value if not wrappable)

unwrapSCOField

Object unwrapSCOField(int fieldNumber,
                      Object value,
                      boolean replaceFieldIfChanged)
Method to unwrap a SCO field (if it is wrapped currently) and return the unwrapped value. If the field is not a SCO field will just return the value. If "replaceFieldIfChanged" is set, we replace the value in the object with the unwrapped value.

Parameters:
fieldNumber - The field number
value - The value to unwrap for this field
replaceFieldIfChanged - Whether to replace the field value in the object if unwrapping the value
Returns:
The unwrapped field 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 value
value - 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.

getEmbeddedOwners

ObjectProvider[] getEmbeddedOwners()
Accessor for the overall owner ObjectProviders of the managed object when embedded.

Returns:
Owning ObjectProviders when embedded (if any)

isEmbedded

boolean isEmbedded()
Convenience accessor for whether this ObjectProvider manages an embedded/serialised object.

Returns:
Whether the managed object is embedded/serialised.

copyFieldsFromObject

void copyFieldsFromObject(Object pc,
                          int[] fieldNumbers)
Convenience method to update our object with the field values from the passed object. Objects need to be of the same type, and the other object should not have a ObjectProvider.

Parameters:
pc - The object that we should copy fields from

runReachability

void runReachability(Set reachables)
Method to run reachability from this ObjectProvider.

Parameters:
reachables - List of reachable ObjectProviders so far

setPcObjectType

void setPcObjectType(short type)
Method to set this ObjectProvider as managing an embedded/serialised object.

Parameters:
type - The type of object being managed

setStoringPC

void setStoringPC()
Method to set the storing PC flag.


unsetStoringPC

void unsetStoringPC()
Method to unset the storing PC flag.


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 object provider that the object has now been flushed to the datastore. This is performed when handling inserts or deletes in a batch external to the ObjectProvider.


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

changeActivityState

void changeActivityState(ActivityState state)
Update the acitvity state.

Parameters:
state - the activity state

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 in the process of 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

loadFieldValues

void loadFieldValues(FieldValues fv)
Convenience method to load the passed field values. Loads the fields using any required fetch plan and calls jdoPostLoad() as appropriate.

Parameters:
fv - Field Values to load (including any fetch plan to use when loading)

getReferencedPC

Object 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()
Fetchs from the database all fields that are not currently loaded and that are in the current fetch group. Called by lifecycle transitions.


loadUnloadedFieldsOfClassInFetchPlan

void loadUnloadedFieldsOfClassInFetchPlan(FetchPlan fetchPlan)
Loads all unloaded fields of the managed class that are in the current FetchPlan. Called by life-cycle transitions.

Parameters:
fetchPlan - The FetchPlan

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.


clearSavedFields

void clearSavedFields()
Method to clear all saved fields on the object.


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.


saveFields

void saveFields()
Method to save all fields of the object.


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

nullifyFields

void nullifyFields()
Nullify fields with reference to persistable or SCO instances


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 object
fieldNumber - 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(Object 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

lock

void lock(short lockMode)
Method to lock the object owned by this ObjectProvider.

Parameters:
lockMode - Lock mode to apply

unlock

void unlock()
Method to unlock the object owned by this ObjectProvider (if locked).


getLockMode

short getLockMode()
Accessor for the current lock mode.

Returns:
Lock mode

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

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

Object attachCopy(Object detachedPC,
                  boolean embedded)
Method to attach to this the detached persistable instance

Parameters:
detachedPC - the detached persistable instance to be attached
embedded - Whether it is embedded
Returns:
The attached copy

attach

void attach(boolean embedded)
Method to attach the object managed by this StateManager.

Parameters:
embedded - Whether it is embedded

attach

void attach(Object trans)
Method to attach the provided transient into the managed instance.

Parameters:
trans - Transient object

detachCopy

Object 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 persistable 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(ObjectProvider op)
Convenience method to retrieve the detach state from the passed ObjectProvider's object

Parameters:
op - ObjectProvider

checkInheritance

void checkInheritance(FieldValues fv)
Deprecated. Dont use this, to be removed

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


Copyright © 2013. All Rights Reserved.