T
- Type of the object being managedpublic interface ObjectProvider<T> extends StateManager
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 ObjectProvider.
|
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 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 |
deletePersistent()
Method to delete the object from persistence.
|
void |
detach(FetchPlanState state)
Method to detach the persistable object.
|
T |
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.
|
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() |
T |
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.
|
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<T> cachedPC,
Object id)
Initialise the ObjectProvider, assigning the specified id to the object.
|
void |
initialiseForDetached(T pc,
Object id,
Object version)
Initialises the ObjectProvider 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 initialiseForHollow
|
void |
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 the ObjectProvider 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 in the process of being deleted.
|
boolean |
isDetaching()
Tests whether this object is in the process of being detached.
|
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 |
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 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 |
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 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(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.
|
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 |
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 |
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.
|
getBooleanField, getByteField, getCharField, getDoubleField, getExecutionContext, 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
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)
ec
- ExecutionContext to connect tocmd
- Metadata for this classvoid disconnect()
void initialiseForHollow(Object id, FieldValues fv, Class<T> 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<T> pcClass)
fv
- the initial field values of the object.pcClass
- Class of the object that this will manage the state forvoid initialiseForHollowPreConstructed(Object id, T pc)
initialiseForHollow(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).id
- the identity of the object.pc
- the object to be managed.void initialiseForPersistentClean(Object id, T pc)
id
- the identity of the object.pc
- The object to be managedvoid initialiseForEmbedded(T pc, boolean copyPc)
pc
- The persistable to manage (see copyPc also)copyPc
- Whether the ObjectProvider should manage a copy of the passed PC or that onevoid initialiseForPersistentNew(T 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(T 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(T pc, Object id, Object version)
pc
- the detach object.id
- the identity of the object.version
- the detached versionvoid initialiseForPNewToBeDeleted(T pc)
pc
- the object to deletevoid initialiseForCachedPC(CachedPC<T> cachedPC, Object id)
cachedPC
- The cached PC objectid
- Id to assign to the persistable objectAbstractClassMetaData getClassMetaData()
ExecutionContext getExecutionContext()
StoreManager getStoreManager()
T 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 fieldvoid 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.boolean isEmbedded()
void updateOwnerFieldInEmbeddedField(int fieldNumber, Object value)
fieldNumber
- The field of this object that is embeddedvalue
- The value of the field (embedded)void 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()
boolean isDeleted()
boolean isDetaching()
void loadFieldValues(FieldValues fv)
fv
- Field Values to load (including any fetch plan to use when loading)T 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 loadUnloadedRelationFields()
void 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 fieldboolean[] 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(T pc)
pc
- The persistable object to usevoid setTransactionalVersion(Object nextVersion)
nextVersion
- version to useObject getTransactionalVersion()
void setVersion(Object version)
version
- The versionObject getVersion()
boolean isVersionLoaded()
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()
T attachCopy(T detachedPC, boolean embedded)
detachedPC
- the detached persistable instance to be attachedembedded
- Whether it is embeddedvoid attach(boolean embedded)
embedded
- Whether it is embeddedvoid attach(T detachedPC)
detachedPC
- Detached objectT 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.void markFieldsAsLoaded(int[] fieldNumbers)
fieldNumbers
- The field numbers to mark as loadedCopyright © 2019. All rights reserved.