public interface ObjectProvider
Modifier and Type | Field and Description |
---|---|
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
|
Modifier and Type | Method and Description |
---|---|
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.
|
static final String ORIGINAL_FIELD_VALUE_KEY_PREFIX
static final short PC
static final short EMBEDDED_PC
static final short EMBEDDED_COLLECTION_ELEMENT_PC
static final short EMBEDDED_MAP_KEY_PC
static final short EMBEDDED_MAP_VALUE_PC
void connect(ExecutionContext ec, AbstractClassMetaData cmd)
void disconnect()
void initialiseForHollow(Object id, FieldValues fv, Class pcClass)
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 forvoid initialiseForHollowAppId(FieldValues fv, Class pcClass)
fv
- the initial field values of the object.pcClass
- Class of the object that this will manage the state forvoid initialiseForHollowPreConstructed(Object id, Object pc)
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).id
- the identity of the object.pc
- the object to be managed.void initialiseForPersistentClean(Object id, Object pc)
id
- the identity of the object.pc
- The object to be managedvoid initialiseForEmbedded(Object pc, boolean copyPc)
pc
- The persistable to manage (see copyPc also)copyPc
- Whether the SM should manage a copy of the passed PC or that onevoid initialiseForPersistentNew(Object pc, FieldValues preInsertChanges)
This constructor is used for assigning state managers to existing instances that are transitioning to a persistent state.
pc
- the instance being make persistent.preInsertChanges
- Any changes to make before insertingvoid initialiseForTransactionalTransient(Object pc)
This constructor is used for assigning state managers to Transient instances that are transitioning to a transient clean state.
pc
- the instance being make persistent.void initialiseForDetached(Object pc, Object id, Object version)
pc
- the detach object.id
- the identity of the object.version
- the detached versionvoid initialiseForPNewToBeDeleted(Object pc)
pc
- the object to deletevoid initialiseForCachedPC(CachedPC cachedPC, Object id)
cachedPC
- The cached PC objectid
- Id to assign to the persistable objectAbstractClassMetaData getClassMetaData()
ExecutionContext getExecutionContext()
Object getObject()
String getObjectAsPrintable()
Object getInternalObjectId()
Object getExternalObjectId()
LifeCycleState getLifecycleState()
void replaceField(int fieldNumber, Object value)
fieldNumber
- (absolute) field number of the fieldvalue
- The new value.void replaceFieldMakeDirty(int fieldNumber, Object value)
fieldNumber
- (absolute) field number of the fieldvalue
- The new value.void replaceFieldValue(int fieldNumber, Object newValue)
fieldNumber
- Number of fieldnewValue
- The new valuevoid replaceFields(int[] fieldNumbers, FieldManager fm)
fieldNumbers
- (absolute) field numbers of the fields to updatefm
- The FieldManagervoid replaceFields(int[] fieldNumbers, FieldManager fm, boolean replaceWhenDirty)
fieldNumbers
- (absolute) field numbers of the fields to updatefm
- The FieldManagerreplaceWhenDirty
- Whether to replace these fields if the field is dirtyvoid replaceNonLoadedFields(int[] fieldNumbers, FieldManager fm)
fieldNumbers
- (absolute) field numbers of the fields to updatefm
- The FieldManagervoid replaceAllLoadedSCOFieldsWithWrappers()
void replaceAllLoadedSCOFieldsWithValues()
void provideFields(int[] fieldNumbers, FieldManager fm)
fieldNumbers
- The numbers of the fieldsfm
- The fieldManagerObject provideField(int fieldNumber)
fieldNumber
- (absolute) field number of the fieldObject wrapSCOField(int fieldNumber, Object value, boolean forInsert, boolean forUpdate, boolean replaceFieldIfChanged)
fieldNumber
- Number of the fieldvalue
- The value to give itforInsert
- Whether the creation of any wrapper should insert this value into the datastoreforUpdate
- Whether the creation of any wrapper should update the datastore with this valuereplaceFieldIfChanged
- Whether to replace the field in the object if wrapping the valueObject unwrapSCOField(int fieldNumber, Object value, boolean replaceFieldIfChanged)
fieldNumber
- The field numbervalue
- The value to unwrap for this fieldreplaceFieldIfChanged
- Whether to replace the field value in the object if unwrapping the valuevoid setAssociatedValue(Object key, Object value)
key
- Key for the valuevalue
- The associated valueObject getAssociatedValue(Object key)
key
- The key for this associated informationvoid removeAssociatedValue(Object key)
key
- The keyint[] getDirtyFieldNumbers()
String[] getDirtyFieldNames()
boolean[] getDirtyFields()
void makeDirty(int field)
field
- The no of field to mark as dirty.ObjectProvider[] getEmbeddedOwners()
boolean isEmbedded()
void copyFieldsFromObject(Object pc, int[] fieldNumbers)
pc
- The object that we should copy fields fromvoid runReachability(Set reachables)
reachables
- List of reachable ObjectProviders so farvoid setPcObjectType(short type)
type
- The type of object being managedvoid setStoringPC()
void unsetStoringPC()
boolean isFlushedToDatastore()
boolean isFlushedNew()
void setFlushedNew(boolean flag)
void flush()
void setFlushing(boolean flushing)
void markAsFlushed()
void locate()
NucleusObjectNotFoundException
- if not presentboolean isWaitingToBeFlushedToDatastore()
void changeActivityState(ActivityState state)
state
- the activity stateboolean isInserting()
boolean isDeleting()
boolean becomingDeleted()
void loadFieldValues(FieldValues fv)
fv
- Field Values to load (including any fetch plan to use when loading)Object getReferencedPC()
void loadField(int fieldNumber)
fieldNumber
- Absolute field numbervoid loadFieldsInFetchPlan(FetchPlanState state)
state
- The FetchPlan statevoid loadFieldFromDatastore(int fieldNumber)
fieldNumber
- The field number.void loadUnloadedFieldsInFetchPlan()
void loadUnloadedFieldsOfClassInFetchPlan(FetchPlan fetchPlan)
fetchPlan
- The FetchPlanvoid loadUnloadedFields()
void unloadNonFetchPlanFields()
void refreshLoadedFields()
void clearSavedFields()
void refreshFieldsInFetchPlan()
void clearNonPrimaryKeyFields()
void restoreFields()
void saveFields()
void clearFields()
void registerTransactional()
boolean isRestoreValues()
void clearLoadedFlags()
void unloadField(String fieldName)
fieldName
- Name of the fieldvoid nullifyFields()
boolean[] getLoadedFields()
int[] getLoadedFieldNumbers()
String[] getLoadedFieldNames()
boolean isLoaded(int absoluteFieldNumber)
boolean getAllFieldsLoaded()
boolean isFieldLoaded(int fieldNumber)
fieldNumber
- The (absolute) field numbervoid updateFieldAfterInsert(Object pc, int fieldNumber)
pc
- The Persistable objectfieldNumber
- The no of field to mark as dirty.void setPostStoreNewObjectId(Object id)
id
- the id received from the datastore. May be an OID, or the key value for an OID, or an application id.void replaceManagedPC(Object pc)
pc
- The persistable object to usevoid setTransactionalVersion(Object nextVersion)
nextVersion
- version to useObject getTransactionalVersion()
void setVersion(Object version)
version
- The versionObject getVersion()
void lock(short lockMode)
lockMode
- Lock mode to applyvoid unlock()
short getLockMode()
void evictFromTransaction()
void enlistInTransaction()
void makeTransactional()
void makeNontransactional()
void makeTransient(FetchPlanState state)
state
- Object containing the state of any fetch plan processingvoid makePersistent()
void makePersistentTransactionalTransient()
void deletePersistent()
Object attachCopy(Object detachedPC, boolean embedded)
detachedPC
- the detached persistable instance to be attachedembedded
- Whether it is embeddedvoid attach(boolean embedded)
embedded
- Whether it is embeddedvoid attach(Object trans)
trans
- Transient objectObject detachCopy(FetchPlanState state)
state
- State for the detachment processvoid detach(FetchPlanState state)
state
- State for the detachment processvoid validate()
void markForInheritanceValidation()
void evict()
void refresh()
void retrieve(boolean fgOnly)
fgOnly
- Whether to retrieve just the current fetch plan fieldsvoid preBegin(Transaction tx)
tx
- The transactionvoid postCommit(Transaction tx)
tx
- The transactionvoid preRollback(Transaction tx)
tx
- The transactionvoid resetDetachState()
void retrieveDetachState(ObjectProvider op)
op
- ObjectProvidervoid checkInheritance(FieldValues fv)
fv
- the initial field values of the object.Copyright © 2019. All rights reserved.