org.datanucleus.jdo.state
Class JDOStateManagerImpl

java.lang.Object
  extended by org.datanucleus.state.AbstractStateManager
      extended by org.datanucleus.jdo.state.JDOStateManagerImpl
All Implemented Interfaces:
StateManager

public class JDOStateManagerImpl
extends AbstractStateManager
implements javax.jdo.spi.StateManager

Implementation of the StateManager. Implemented here as one StateManager per Object so adds on functionality particular to each object. All PersistenceCapable objects will have a StateManager when they have had communication with the PersistenceManager. They will typically always have an identity also. The exception to that is for embedded/serialised objects.

Embedded/Serialised Objects

An object that is being embedded/serialised in an owning object will NOT have an identity unless the object is subject to a makePersistent() call also. When an object is embedded/serialised and a field is changed, the field will NOT be marked as dirty (unless it is also an object in its own right with an identity). When a field is changed any owning objects are updated so that they can update their tables accordingly.

Performance and Memory

StateManagers are very performance-critical, because for each PersistentCapable object made persistent, there will be one StateManager instance, adding up to the total memory footprint of that object. In heap profiling analysis, JDOStateManagerImpls showed to consume bytes 169 per StateManager by itself and about 500 bytes per StateManager when taking PC-individual child-object (like the OID) referred by the StateManager into account. With small Java objects this can mean a substantial memory overhead and for applications using such small objects can be critical. For this reason the StateManager should always be minimal in memory consumption.


Field Summary
protected static java.util.HashMap<java.lang.String,ObjectValueGenerator> objectValGenerators
          Cache of object-value-generators, keyed by their symbolic name.
 
Fields inherited from class org.datanucleus.state.AbstractStateManager
cmd, currFM, dirty, dirtyFields, loadedFields, LOCALISER, lockMode, myFP, myID, myInternalID, myLC, myOM, myPC, myVersion, pcObjectType, readWriteLock, restoreValues, transactionalVersion
 
Constructor Summary
JDOStateManagerImpl(ObjectManager om, AbstractClassMetaData cmd)
          Basic constructor.
 
Method Summary
 void addEmbeddedOwner(StateManager ownerSM, int ownerFieldNumber)
          Method to register an owner StateManager with this embedded/serialised object.
 void addInsertionNotifier(StateManager sm, ActivityState activityState)
          Method to add a notifier that we must contact when we have finished our insertion.
 void attach(boolean embedded)
          Method to attach the object managed by this StateManager.
 java.lang.Object attachCopy(java.lang.Object obj, boolean embedded)
          Method to attach a copy of the detached persistable instance and return the (attached) copy.
 boolean becomingDeleted()
          Whether this object is moving to a deleted state.
 CachedPC cache()
          Method to return an L2 cacheable form of the managed object.
 void changeActivityState(ActivityState activityState)
          Change the activity state.
 void checkInheritance(FieldValues fv)
          Look to the database to determine which class this object is.
 void checkManagedRelations()
          Method to check all updated managed relations in this object.
 void clearFields()
          Method to clear all fields of the object.
 void clearLoadedFlags()
          Method to clear all loaded flags on the object.
 void clearManagedRelations()
          Method to clear all initial values for bidirectional fields involved in "managed relationships".
 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 copyFieldsFromObject(javax.jdo.spi.PersistenceCapable 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 this object.
 java.lang.Object detachCopy(FetchPlanState state)
          Method to make detached copy of this instance If the object is detachable then the copy will be migrated to DETACHED state, otherwise will migrate the copy to TRANSIENT.
 void disconnect()
          Disconnect the StateManager from the PersistenceManager and PC object.
protected  boolean disconnectClone(javax.jdo.spi.PersistenceCapable pc)
          Method to disconnect any cloned persistence capable objects from their StateManager.
 void dump(java.io.PrintWriter out)
          Utility to dump the contents of the StateManager.
 void enlistInTransaction()
          Method to enlist the managed object in the current transaction.
 void evictFromTransaction()
          Method to evict the managed object from the current transaction.
 void flush()
          Flushes any outstanding changes to the object to the datastore.
 java.lang.Object getAssociatedValue(java.lang.Object key)
          Accessor for an associated value stored with this object.
 StateManager[] getEmbeddedOwners()
          Accessor for the owning StateManagers for the managed object when stored embedded.
 java.lang.Object getExternalObjectId(java.lang.Object obj)
          Return an object id that the user can use.
 java.lang.Object getObjectId(javax.jdo.spi.PersistenceCapable pc)
          Return the object representing the JDO identity of the calling instance.
 ObjectProvider getObjectProvider()
          Accessor for the ObjectProvider.
protected static ObjectValueGenerator getObjectValueGenerator(ObjectManager om, java.lang.String genName)
          Method to find an object value generator based on its name.
 javax.jdo.PersistenceManager getPersistenceManager(javax.jdo.spi.PersistenceCapable pc)
          Accessor for the PersistenceManager that owns this instance.
 java.lang.Object getReferencedPC()
          Accessor for the referenced PC object when we are attaching or detaching.
 RelationshipManager getRelationshipManager()
          Accessor for the relationship manager, and create if not existing and we are managing relations.
 java.lang.Object getTransactionalObjectId(javax.jdo.spi.PersistenceCapable pc)
          Return the object representing the JDO identity of the calling instance.
 void initialiseForCachedPC(CachedPC cachedPC, java.lang.Object id, java.lang.Class pcClass)
          Initialise to create a StateManager for a PersistenceCapable object, assigning the specified id to the object.
 void initialiseForDetached(java.lang.Object pc, java.lang.Object id, java.lang.Object version)
          Initialises the StateManager to manage a PersistenceCapable object in detached state.
 void initialiseForEmbedded(java.lang.Object pc, boolean copyPc)
          Initialises a state manager to manage a PersistenceCapable instance that will be EMBEDDED/SERIALISED into another PersistenceCapable object.
 void initialiseForHollow(java.lang.Object id, FieldValues fv, java.lang.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, java.lang.Class pcClass)
          Initialises a state manager to manage a HOLLOW / P_CLEAN instance having the given FieldValues.
 void initialiseForHollowPreConstructed(java.lang.Object id, java.lang.Object pc)
          Initialises a state manager to manage the given hollow instance having the given object ID.
 void initialiseForPersistentClean(java.lang.Object id, java.lang.Object pc)
          Initialises a state manager to manage the passed persistent instance having the given object ID.
 void initialiseForPersistentNew(java.lang.Object pc, FieldValues preInsertChanges)
          Initialises a state manager to manage a transient instance that is becoming newly persistent.
 void initialiseForPNewToBeDeleted(java.lang.Object pc)
          Initialises the StateManager to manage a PersistenceCapable object that is not persistent but is about to be deleted.
 void initialiseForTransactionalTransient(java.lang.Object pc)
          Initialises a state manager to manage a Transactional Transient instance.
 boolean isDeleting()
          Tests whether this object is being deleted.
 boolean isDetaching()
          Tests whether this object is being detached.
 boolean isInserting()
          Tests whether this object is being inserted.
 boolean isLoaded(javax.jdo.spi.PersistenceCapable pc, int field)
          Return true if the field is cached in the calling instance.
 boolean isUpdatingFieldForPostInsert()
          Convenience method to return if we are in the phase of performing postInsert updates due to related objects having been inserted.
 boolean isWaitingToBeFlushedToDatastore()
          Accessor for whether the instance is newly persistent yet hasnt yet been 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.
protected  void loadSpecifiedFields(int[] fieldNumbers)
          Fetch the specified fields from the database.
 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 loadUnloadedFieldsInFetchPlanAndVersion()
          Fetchs from the database all fields in current fetch plan that are not currently loaded as well as the version.
 void loadUnloadedFieldsOfClassInFetchPlan(FetchPlan fetchPlan)
          Fetchs from the database all fields in the actual fetch plan.
 void locate()
          Locate the object in the datastore.
 void makeDirty(int field)
          Marks the given field dirty.
 void makeDirty(javax.jdo.spi.PersistenceCapable pc, java.lang.String fieldName)
          Mark the associated PersistenceCapable field dirty.
 void makePersistent()
          Method to make the object persistent.
 void makeTransactional()
          Method to change the object state to transactional.
 void makeTransient(FetchPlanState state)
          Method to change the object state to transient.
 void markForInheritanceValidation()
          Mark the state manager as needing to validate the inheritance of the managed object existence before loading fields.
protected  void markPKFieldsAsLoaded()
          Convenience method to mark PK fields as loaded (if using app id).
 void nullifyFields()
          Nullify fields with reference to PersistenceCapable or SCO instances
protected  void postStateChange()
          Method called after a change in state.
 void preSerialize(javax.jdo.spi.PersistenceCapable pc)
          Guarantee that the serializable transactional and persistent fields are loaded into the instance.
protected  void preStateChange()
          Method called before a change in state.
 void processManagedRelations()
          Method to process all updated managed relations in this object.
 java.lang.Object provideField(int fieldNumber)
          Method to return the current value of a particular field.
 void provideFields(int[] fieldNumbers, FieldManager fm)
          Called from the StoreManager after StoreManager.update() is called to obtain updated values from the PersistenceCapable associated with this StateManager.
 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 removeEmbeddedOwner(javax.jdo.spi.StateManager ownerSM, int ownerFieldNumber)
          Method to remove an owner StateManager from this embedded/serialised objects owners list.
 void replaceAllLoadedSCOFieldsWithValues()
          Method to replace all loaded SCO fields that have wrappers with their value.
 void replaceAllLoadedSCOFieldsWithWrappers()
          Method to replace all loaded SCO fields with wrappers.
 void replaceField(int fieldNumber, java.lang.Object value, boolean makeDirty)
          Method to change the value of a particular field.
 void replaceFields(int[] fieldNumbers, FieldManager fm)
          Called from the StoreManager to refresh data in the PersistenceCapable object associated with this StateManager.
 void replaceFields(int[] fieldNumbers, FieldManager fm, boolean replaceWhenDirty)
          Called from the StoreManager to refresh data in the PersistenceCapable object associated with this StateManager.
 void replaceFieldValue(int fieldNumber, java.lang.Object newValue)
          Convenience method to change the value of a field that is assumed loaded.
 void replaceManagedPC(javax.jdo.spi.PersistenceCapable pc)
          Method that replaces the PC managed by this StateManager to be the supplied object.
 void replaceNonLoadedFields(int[] fieldNumbers, FieldManager fm)
          Called from the StoreManager to refresh data in the PersistenceCapable object associated with this StateManager.
 java.lang.Object[] replacingDetachedState(javax.jdo.spi.Detachable pc, java.lang.Object[] currentState)
          Method to update the "detached state" in the detached object to obtain the "detached state" from the detached object, or to reset it (to null).
 byte replacingFlags(javax.jdo.spi.PersistenceCapable pc)
          The StateManager uses this method to supply the value of jdoFlags to the associated PersistenceCapable instance.
 javax.jdo.spi.StateManager replacingStateManager(javax.jdo.spi.PersistenceCapable pc, javax.jdo.spi.StateManager sm)
          Replace the current value of jdoStateManager.
 void resetDetachState()
          Convenience method to reset the detached state in the current object.
 void restoreFields()
          Method to restore all fields of the object.
 void retrieveDetachState(StateManager sm)
          Convenience method to retrieve the detach state from the passed State Manager's object.
 void runReachability(java.util.Set reachables)
          Method to mark an object for reachability.
 void saveFields()
          Method to save all fields of the object.
 void setAssociatedValue(java.lang.Object key, java.lang.Object value)
          Method to set an associated value stored with this object.
 void setBooleanField(javax.jdo.spi.PersistenceCapable pc, int field, boolean currentValue, boolean newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void setByteField(javax.jdo.spi.PersistenceCapable pc, int field, byte currentValue, byte newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void setCharField(javax.jdo.spi.PersistenceCapable pc, int field, char currentValue, char newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void setDoubleField(javax.jdo.spi.PersistenceCapable pc, int field, double currentValue, double newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void setFloatField(javax.jdo.spi.PersistenceCapable pc, int field, float currentValue, float newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void setIntField(javax.jdo.spi.PersistenceCapable pc, int field, int currentValue, int newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void setLongField(javax.jdo.spi.PersistenceCapable pc, int field, long currentValue, long newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void setObjectField(javax.jdo.spi.PersistenceCapable pc, int field, java.lang.Object currentValue, java.lang.Object newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void setPostStoreNewObjectId(java.lang.Object id)
          If the id is obtained after inserting the object into the database, set new a new id for persistent classes (for example, increment).
 void setShortField(javax.jdo.spi.PersistenceCapable pc, int field, short currentValue, short newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void setStoringPC()
          Method to set the storing PC flag.
 void setStringField(javax.jdo.spi.PersistenceCapable pc, int field, java.lang.String currentValue, java.lang.String newValue)
          This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.
 void unloadField(java.lang.String fieldName)
          Convenience method to unload a field/property.
 void unloadNonFetchPlanFields()
          Method that will unload all fields that are not in the FetchPlan.
 void unsetStoringPC()
          Method to unset the storing PC flag.
 java.lang.Object unwrapSCOField(int fieldNumber, java.lang.Object value, boolean replaceFieldIfChanged)
          Method to unwrap a SCO field (if it is wrapped currently).
 void updateFieldAfterInsert(java.lang.Object pc, int fieldNumber)
          Marks the given field as being required to be updated when the specified object has been inserted.
 void validate()
          Validates whether the persistence capable instance exists in the datastore.
 java.lang.Object wrapSCOField(int fieldNumber, java.lang.Object value, boolean forInsert, boolean forUpdate, boolean replaceFieldIfChanged)
          Method to create a new SCO wrapper for the specified field.
 
Methods inherited from class org.datanucleus.state.AbstractStateManager
clearDirtyFlags, clearDirtyFlags, clearFlags, clearFlags, equals, evict, getAllFieldNumbers, getAllFieldsLoaded, getBooleanField, getByteField, getCallbackHandler, getCharField, getClassMetaData, getDirtyFieldNames, getDirtyFieldNumbers, getDirtyFields, getDoubleField, getFlagsSetTo, getFlagsSetTo, getFloatField, getHighestFieldNumber, getInternalObjectId, getIntField, getLifecycleState, getLoadedFieldNames, getLoadedFieldNumbers, getLoadedFields, getLockMode, getLongField, getMetaDataManager, getNonPrimaryKeyFieldNumbers, getNonPrimaryKeyFields, getObject, getObjectField, getObjectManager, getPcObjectType, getSecondClassMutableFieldNumbers, getSecondClassMutableFields, getShortField, getStoreManager, getStringField, getTransactionalVersion, getVersion, initialiseFieldInformation, isDefaultFetchGroupLoaded, isDeleted, isDirty, isEmbedded, isFetchPlanLoaded, isFieldLoaded, isNew, isPersistent, isRestoreValues, isTransactional, lock, makeNontransactional, makePersistentTransactionalTransient, peekField, postCommit, preBegin, preRollback, providedBooleanField, providedByteField, providedCharField, providedDoubleField, providedFloatField, providedIntField, providedLongField, providedObjectField, providedShortField, providedStringField, refresh, replacingBooleanField, replacingByteField, replacingCharField, replacingDoubleField, replacingFloatField, replacingIntField, replacingLongField, replacingObjectField, replacingShortField, replacingStringField, retrieve, retrieve, setPcObjectType, setRestoreValues, setTransactionalVersion, setVersion, toString, transitionReadField, transitionWriteField, unlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jdo.spi.StateManager
getBooleanField, getByteField, getCharField, getDoubleField, getFloatField, getIntField, getLongField, getObjectField, getShortField, getStringField, getVersion, isDeleted, isDirty, isNew, isPersistent, isTransactional, providedBooleanField, providedByteField, providedCharField, providedDoubleField, providedFloatField, providedIntField, providedLongField, providedObjectField, providedShortField, providedStringField, replacingBooleanField, replacingByteField, replacingCharField, replacingDoubleField, replacingFloatField, replacingIntField, replacingLongField, replacingObjectField, replacingShortField, replacingStringField
 

Field Detail

objectValGenerators

protected static java.util.HashMap<java.lang.String,ObjectValueGenerator> objectValGenerators
Cache of object-value-generators, keyed by their symbolic name.

Constructor Detail

JDOStateManagerImpl

public JDOStateManagerImpl(ObjectManager om,
                           AbstractClassMetaData cmd)
Basic constructor. Delegates to the superclass.

Parameters:
om - The ObjectManager
cmd - the metadata for the class.
Method Detail

initialiseForHollow

public void initialiseForHollow(java.lang.Object id,
                                FieldValues fv,
                                java.lang.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).

Specified by:
initialiseForHollow in interface StateManager
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

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

Specified by:
initialiseForHollowAppId in interface StateManager
Parameters:
fv - the initial field values of the object.
pcClass - Class of the object that this will manage the state for

initialiseForHollowPreConstructed

public void initialiseForHollowPreConstructed(java.lang.Object id,
                                              java.lang.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.

Specified by:
initialiseForHollowPreConstructed in interface StateManager
Parameters:
id - the identity of the object.
pc - the object to be managed.

initialiseForPersistentClean

public void initialiseForPersistentClean(java.lang.Object id,
                                         java.lang.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.

Specified by:
initialiseForPersistentClean in interface StateManager
Parameters:
id - the identity of the object.
pc - The object to be managed

initialiseForEmbedded

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

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

initialiseForPersistentNew

public void initialiseForPersistentNew(java.lang.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.

Specified by:
initialiseForPersistentNew in interface StateManager
Parameters:
pc - the instance being make persistent.
preInsertChanges - Any changes to make before inserting

initialiseForTransactionalTransient

public void initialiseForTransactionalTransient(java.lang.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.

Specified by:
initialiseForTransactionalTransient in interface StateManager
Parameters:
pc - the instance being make persistent.

initialiseForDetached

public void initialiseForDetached(java.lang.Object pc,
                                  java.lang.Object id,
                                  java.lang.Object version)
Initialises the StateManager to manage a PersistenceCapable object in detached state.

Specified by:
initialiseForDetached in interface StateManager
Parameters:
pc - the detach object.
id - the identity of the object.
version - the detached version

initialiseForPNewToBeDeleted

public void initialiseForPNewToBeDeleted(java.lang.Object pc)
Initialises the StateManager to manage a PersistenceCapable object that is not persistent but is about to be deleted.

Specified by:
initialiseForPNewToBeDeleted in interface StateManager
Parameters:
pc - the object to delete

initialiseForCachedPC

public void initialiseForCachedPC(CachedPC cachedPC,
                                  java.lang.Object id,
                                  java.lang.Class pcClass)
Initialise to create a StateManager for a PersistenceCapable object, 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 PM.

Specified by:
initialiseForCachedPC in interface StateManager
Parameters:
cachedPC - The cached PC object
id - Id to assign to the PersistenceCapable object
pcClass - Class of the object that this will manage the state for

cache

public CachedPC cache()
Method to return an L2 cacheable form of the managed object.

Specified by:
cache in interface StateManager
Returns:
The object suitable for L2 caching

checkInheritance

public void checkInheritance(FieldValues fv)
Look to the database to determine which class this object is. This parameter is a hint. Set false, if it's already determined the correct pcClass for this pc "object" in a certain level in the hierarchy. Set to true and it will look to the database.

Specified by:
checkInheritance in interface StateManager
Parameters:
fv - the initial field values of the object.

getObjectValueGenerator

protected static ObjectValueGenerator getObjectValueGenerator(ObjectManager om,
                                                              java.lang.String genName)
Method to find an object value generator based on its name. Caches the generators once generated.

Parameters:
om - ObjectManager
genName - The generator name
Returns:
The value generator (if any)
Throws:
NucleusException - if no generator of that name is found

loadFieldValues

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

Specified by:
loadFieldValues in interface StateManager
Parameters:
fv - Field Values to load (including any fetch plan to use when loading)

replaceManagedPC

public void replaceManagedPC(javax.jdo.spi.PersistenceCapable pc)
Method that replaces the PC managed by this StateManager to be the supplied object. This happens when we want to get an object for an id and create a Hollow object, and then validate against the datastore. This validation can pull in a new object graph from the datastore (e.g for DB4O)

Specified by:
replaceManagedPC in interface StateManager
Parameters:
pc - The PersistenceCapable to use

copyFieldsFromObject

public void copyFieldsFromObject(javax.jdo.spi.PersistenceCapable 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 StateManager.

Specified by:
copyFieldsFromObject in interface StateManager
Parameters:
pc - The object that we should copy fields from

enlistInTransaction

public void enlistInTransaction()
Method to enlist the managed object in the current transaction.

Specified by:
enlistInTransaction in interface StateManager

evictFromTransaction

public void evictFromTransaction()
Method to evict the managed object from the current transaction.

Specified by:
evictFromTransaction in interface StateManager

saveFields

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

Specified by:
saveFields in interface StateManager

restoreFields

public void restoreFields()
Method to restore all fields of the object.

Specified by:
restoreFields in interface StateManager

clearFields

public void clearFields()
Method to clear all fields of the object.

Specified by:
clearFields in interface StateManager

clearNonPrimaryKeyFields

public void clearNonPrimaryKeyFields()
Method to clear all fields that are not part of the primary key of the object.

Specified by:
clearNonPrimaryKeyFields in interface StateManager

clearSavedFields

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

Specified by:
clearSavedFields in interface StateManager

clearLoadedFlags

public void clearLoadedFlags()
Method to clear all loaded flags on the object. Note that the contract of this method implies, especially for object database backends, that the memory form of the object is outdated. Thus, for features like implicit saving of dirty object subgraphs should be switched off for this PC, even if the object actually looks like being dirty (because it is being changed to null values).

Specified by:
clearLoadedFlags in interface StateManager

makeDirty

public void makeDirty(int field)
Marks the given field dirty.

Specified by:
makeDirty in interface StateManager
Parameters:
field - The no of field to mark as dirty.

makeDirty

public void makeDirty(javax.jdo.spi.PersistenceCapable pc,
                      java.lang.String fieldName)
Mark the associated PersistenceCapable field dirty.

Parameters:
pc - the calling PersistenceCapable instance
fieldName - the name of the field

getPersistenceManager

public javax.jdo.PersistenceManager getPersistenceManager(javax.jdo.spi.PersistenceCapable pc)
Accessor for the PersistenceManager that owns this instance.

Parameters:
pc - The PersistenceCapable instance
Returns:
The PersistenceManager that owns this instance

getObjectId

public java.lang.Object getObjectId(javax.jdo.spi.PersistenceCapable pc)
Return the object representing the JDO identity of the calling instance. According to the JDO specification, if the JDO identity is being changed in the current transaction, this method returns the JDO identify as of the beginning of the transaction.

Specified by:
getObjectId in interface StateManager
Parameters:
pc - the calling PersistenceCapable instance
Returns:
the object representing the JDO identity of the calling instance

setPostStoreNewObjectId

public void setPostStoreNewObjectId(java.lang.Object id)
If the id is obtained after inserting the object into the database, set new a new id for persistent classes (for example, increment).

Specified by:
setPostStoreNewObjectId in interface StateManager
Parameters:
id - the id received from the datastore

getExternalObjectId

public java.lang.Object getExternalObjectId(java.lang.Object obj)
Return an object id that the user can use.

Specified by:
getExternalObjectId in interface StateManager
Parameters:
obj - the PersistenceCapable object
Returns:
the object id

replacingStateManager

public javax.jdo.spi.StateManager replacingStateManager(javax.jdo.spi.PersistenceCapable pc,
                                                        javax.jdo.spi.StateManager sm)
Replace the current value of jdoStateManager.

This method is called by the PersistenceCapable whenever jdoReplaceStateManager is called and there is already an owning StateManager. This is a security precaution to ensure that the owning StateManager is the only source of any change to its reference in the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
sm - the proposed new value for the jdoStateManager
Returns:
the new value for the jdoStateManager

getTransactionalObjectId

public java.lang.Object getTransactionalObjectId(javax.jdo.spi.PersistenceCapable pc)
Return the object representing the JDO identity of the calling instance. If the JDO identity is being changed in the current transaction, this method returns the current identity as changed in the transaction.

Parameters:
pc - the calling PersistenceCapable instance
Returns:
the object representing the JDO identity of the calling instance

loadSpecifiedFields

protected void loadSpecifiedFields(int[] fieldNumbers)
Fetch the specified fields from the database.

Parameters:
fieldNumbers - the numbers of the field(s) to fetch.

loadField

public void loadField(int fieldNumber)
Convenience method to load the specified field if not loaded.

Specified by:
loadField in interface StateManager
Parameters:
fieldNumber - Absolute field number

loadUnloadedFields

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

Specified by:
loadUnloadedFields in interface StateManager

loadFieldsInFetchPlan

public 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. Used as a precursor to detaching objects at commit since fields can't be loaded during the postCommit phase when the detach actually happens.

Specified by:
loadFieldsInFetchPlan in interface StateManager
Parameters:
state - The FetchPlan state

loadUnloadedFieldsInFetchPlan

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

Specified by:
loadUnloadedFieldsInFetchPlan in interface StateManager

loadUnloadedFieldsInFetchPlanAndVersion

public void loadUnloadedFieldsInFetchPlanAndVersion()
Fetchs from the database all fields in current fetch plan that are not currently loaded as well as the version. Called by lifecycle transitions.


loadUnloadedFieldsOfClassInFetchPlan

public void loadUnloadedFieldsOfClassInFetchPlan(FetchPlan fetchPlan)
Fetchs from the database all fields in the actual fetch plan. Called by life-cycle transitions.

Specified by:
loadUnloadedFieldsOfClassInFetchPlan in interface StateManager
Parameters:
fetchPlan - The FetchPlan

unloadField

public void unloadField(java.lang.String fieldName)
Convenience method to unload a field/property.

Specified by:
unloadField in interface StateManager
Parameters:
fieldName - Name of the field/property
Throws:
NucleusUserException - if the object managed by this StateManager is embedded

markPKFieldsAsLoaded

protected void markPKFieldsAsLoaded()
Convenience method to mark PK fields as loaded (if using app id).


refreshFieldsInFetchPlan

public void refreshFieldsInFetchPlan()
Refreshes from the database all fields in fetch plan. Called by life-cycle transitions when the object undergoes a "transitionRefresh".

Specified by:
refreshFieldsInFetchPlan in interface StateManager

refreshLoadedFields

public void refreshLoadedFields()
Refreshes from the database all fields currently loaded. Called by life-cycle transitions when making transactional or reading fields.

Specified by:
refreshLoadedFields in interface StateManager

unloadNonFetchPlanFields

public void unloadNonFetchPlanFields()
Method that will unload all fields that are not in the FetchPlan. This is typically for use when the instance is being refreshed.

Specified by:
unloadNonFetchPlanFields in interface StateManager

loadFieldFromDatastore

public void loadFieldFromDatastore(int fieldNumber)
Convenience method to load a field from the datastore. Used in attaching fields and checking their old values (so we dont want any postLoad method being called). TODO Merge this with one of the loadXXXFields methods.

Specified by:
loadFieldFromDatastore in interface StateManager
Parameters:
fieldNumber - The field number.

isLoaded

public boolean isLoaded(javax.jdo.spi.PersistenceCapable pc,
                        int field)
Return true if the field is cached in the calling instance. In this implementation, isLoaded() will always return true. If the field is not loaded, it will be loaded as a side effect of the call to this method. If it is in the default fetch group, the default fetch group, including this field, will be loaded.

Specified by:
isLoaded in interface StateManager
Parameters:
pc - the calling PersistenceCapable instance
field - the absolute field number
Returns:
always returns true (this implementation)

setBooleanField

public void setBooleanField(javax.jdo.spi.PersistenceCapable pc,
                            int field,
                            boolean currentValue,
                            boolean newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

setByteField

public void setByteField(javax.jdo.spi.PersistenceCapable pc,
                         int field,
                         byte currentValue,
                         byte newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

setCharField

public void setCharField(javax.jdo.spi.PersistenceCapable pc,
                         int field,
                         char currentValue,
                         char newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

setDoubleField

public void setDoubleField(javax.jdo.spi.PersistenceCapable pc,
                           int field,
                           double currentValue,
                           double newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

setFloatField

public void setFloatField(javax.jdo.spi.PersistenceCapable pc,
                          int field,
                          float currentValue,
                          float newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

setIntField

public void setIntField(javax.jdo.spi.PersistenceCapable pc,
                        int field,
                        int currentValue,
                        int newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

setLongField

public void setLongField(javax.jdo.spi.PersistenceCapable pc,
                         int field,
                         long currentValue,
                         long newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

setShortField

public void setShortField(javax.jdo.spi.PersistenceCapable pc,
                          int field,
                          short currentValue,
                          short newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

setStringField

public void setStringField(javax.jdo.spi.PersistenceCapable pc,
                           int field,
                           java.lang.String currentValue,
                           java.lang.String newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

setObjectField

public void setObjectField(javax.jdo.spi.PersistenceCapable pc,
                           int field,
                           java.lang.Object currentValue,
                           java.lang.Object newValue)
This method is called by the associated PersistenceCapable when the corresponding mutator method (setXXX()) is called on the PersistenceCapable.

Specified by:
setObjectField in interface StateManager
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the new value for the field

getRelationshipManager

public RelationshipManager getRelationshipManager()
Accessor for the relationship manager, and create if not existing and we are managing relations.

Specified by:
getRelationshipManager in interface StateManager
Returns:
The Relationship manager

checkManagedRelations

public void checkManagedRelations()
Method to check all updated managed relations in this object.

Specified by:
checkManagedRelations in interface StateManager

processManagedRelations

public void processManagedRelations()
Method to process all updated managed relations in this object.

Specified by:
processManagedRelations in interface StateManager

clearManagedRelations

public void clearManagedRelations()
Method to clear all initial values for bidirectional fields involved in "managed relationships".

Specified by:
clearManagedRelations in interface StateManager

replaceFieldValue

public void replaceFieldValue(int fieldNumber,
                              java.lang.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. If the object is deleted then does nothing. Only for use in management of relations.

Specified by:
replaceFieldValue in interface StateManager
Parameters:
fieldNumber - Number of field
newValue - The new value

replacingFlags

public byte replacingFlags(javax.jdo.spi.PersistenceCapable pc)
The StateManager uses this method to supply the value of jdoFlags to the associated PersistenceCapable instance.

Parameters:
pc - the calling PersistenceCapable instance
Returns:
the value of jdoFlags to be stored in the PersistenceCapable instance

provideField

public java.lang.Object provideField(int fieldNumber)
Method to return the current value of a particular field.

Specified by:
provideField in interface StateManager
Parameters:
fieldNumber - Number of field
Returns:
The value of the field

replaceField

public void replaceField(int fieldNumber,
                         java.lang.Object value,
                         boolean makeDirty)
Method to change the value of a particular field.

Specified by:
replaceField in interface StateManager
Parameters:
fieldNumber - Number of field
value - New value
makeDirty - Whether to make the field dirty when replacing it

provideFields

public void provideFields(int[] fieldNumbers,
                          FieldManager fm)
Called from the StoreManager after StoreManager.update() is called to obtain updated values from the PersistenceCapable associated with this StateManager.

Specified by:
provideFields in interface StateManager
Parameters:
fieldNumbers - An array of field numbers to be updated by the Store
fm - The updated values are stored in this object. This object is only valid for the duration of this call.

replaceFields

public void replaceFields(int[] fieldNumbers,
                          FieldManager fm,
                          boolean replaceWhenDirty)
Called from the StoreManager to refresh data in the PersistenceCapable object associated with this StateManager.

Specified by:
replaceFields in interface StateManager
Parameters:
fieldNumbers - An array of field numbers to be refreshed by the Store
fm - The updated values are stored in this object. This object is only valid for the duration of this call.
replaceWhenDirty - Whether to replace the fields when they are dirty here

replaceFields

public void replaceFields(int[] fieldNumbers,
                          FieldManager fm)
Called from the StoreManager to refresh data in the PersistenceCapable object associated with this StateManager.

Specified by:
replaceFields in interface StateManager
Parameters:
fieldNumbers - An array of field numbers to be refreshed by the Store
fm - The updated values are stored in this object. This object is only valid for the duration of this call.

replaceNonLoadedFields

public void replaceNonLoadedFields(int[] fieldNumbers,
                                   FieldManager fm)
Called from the StoreManager to refresh data in the PersistenceCapable object associated with this StateManager. Only not loaded fields are refreshed

Specified by:
replaceNonLoadedFields in interface StateManager
Parameters:
fieldNumbers - An array of field numbers to be refreshed by the Store
fm - The updated values are stored in this object. This object is only valid for the duration of this call.

addEmbeddedOwner

public void addEmbeddedOwner(StateManager ownerSM,
                             int ownerFieldNumber)
Method to register an owner StateManager with this embedded/serialised object.

Specified by:
addEmbeddedOwner in interface StateManager
Parameters:
ownerSM - The owning State Manager.
ownerFieldNumber - The field number in the owner that the embedded/serialised object is stored as

removeEmbeddedOwner

public void removeEmbeddedOwner(javax.jdo.spi.StateManager ownerSM,
                                int ownerFieldNumber)
Method to remove an owner StateManager from this embedded/serialised objects owners list.

Parameters:
ownerSM - The owner to remove
ownerFieldNumber - The field in the owner where this object is stored

getEmbeddedOwners

public StateManager[] getEmbeddedOwners()
Accessor for the owning StateManagers for the managed object when stored embedded. Should really only have a single owner but users could, in principle, assign it to multiple.

Specified by:
getEmbeddedOwners in interface StateManager
Returns:
StateManagers owning this embedded object.

replaceAllLoadedSCOFieldsWithWrappers

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

Specified by:
replaceAllLoadedSCOFieldsWithWrappers in interface StateManager

replaceAllLoadedSCOFieldsWithValues

public void replaceAllLoadedSCOFieldsWithValues()
Method to replace all loaded SCO fields that have wrappers with their value. If the loaded field doesnt have a SCO wrapper nothing happens to that field.

Specified by:
replaceAllLoadedSCOFieldsWithValues in interface StateManager

unwrapSCOField

public java.lang.Object unwrapSCOField(int fieldNumber,
                                       java.lang.Object value,
                                       boolean replaceFieldIfChanged)
Method to unwrap a SCO field (if it is wrapped currently). 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.

Specified by:
unwrapSCOField in interface StateManager
Parameters:
fieldNumber - The field number
value - The value for the field
replaceFieldIfChanged - Whether to replace the field value in the object if unwrapping the value
Returns:
The unwrapped field value

wrapSCOField

public java.lang.Object wrapSCOField(int fieldNumber,
                                     java.lang.Object value,
                                     boolean forInsert,
                                     boolean forUpdate,
                                     boolean replaceFieldIfChanged)
Method to create a new SCO wrapper for the specified field. If the field is not a SCO field will just return the value.

Specified by:
wrapSCOField in interface StateManager
Parameters:
fieldNumber - The field number
value - The value to initialise the wrapper with (if any)
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)

runReachability

public void runReachability(java.util.Set reachables)
Method to mark an object for reachability. Provides the basis for "persistence-by-reachability", but run at commit time only. The reachability algorithm is also run at makePersistent, but directly via InsertRequest.

Specified by:
runReachability in interface StateManager
Parameters:
reachables - List of object ids currently logged as reachable

makePersistent

public void makePersistent()
Method to make the object persistent.

Specified by:
makePersistent in interface StateManager

isInserting

public boolean isInserting()
Tests whether this object is being inserted.

Specified by:
isInserting in interface StateManager
Returns:
true if this instance is inserting.

isDeleting

public boolean isDeleting()
Tests whether this object is being deleted.

Specified by:
isDeleting in interface StateManager
Returns:
true if this instance is being deleted.

isDetaching

public boolean isDetaching()
Tests whether this object is being detached.

Specified by:
isDetaching in interface StateManager
Returns:
true if this instance is detaching.

isWaitingToBeFlushedToDatastore

public boolean isWaitingToBeFlushedToDatastore()
Accessor for whether the instance is newly persistent yet hasnt yet been flushed to the datastore.

Specified by:
isWaitingToBeFlushedToDatastore in interface StateManager
Returns:
Whether not yet flushed to the datastore

changeActivityState

public void changeActivityState(ActivityState activityState)
Change the activity state.

Specified by:
changeActivityState in interface StateManager
Parameters:
activityState - the new state

addInsertionNotifier

public void addInsertionNotifier(StateManager sm,
                                 ActivityState activityState)
Method to add a notifier that we must contact when we have finished our insertion.

Parameters:
sm - the state manager
activityState - the ActivityState (unused)

updateFieldAfterInsert

public void updateFieldAfterInsert(java.lang.Object pc,
                                   int fieldNumber)
Marks the given field as being required to be updated when the specified object has been inserted.

Specified by:
updateFieldAfterInsert in interface StateManager
Parameters:
pc - The Persistable object
fieldNumber - Number of the field.

isUpdatingFieldForPostInsert

public boolean isUpdatingFieldForPostInsert()
Convenience method to return if we are in the phase of performing postInsert updates due to related objects having been inserted.

Specified by:
isUpdatingFieldForPostInsert in interface StateManager
Returns:
Whether we are updating for postInsert

setAssociatedValue

public void setAssociatedValue(java.lang.Object key,
                               java.lang.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).

Specified by:
setAssociatedValue in interface StateManager
Parameters:
key - Key for the value
value - The associated value

getAssociatedValue

public java.lang.Object getAssociatedValue(java.lang.Object key)
Accessor for 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).

Specified by:
getAssociatedValue in interface StateManager
Parameters:
key - Key for the value
Returns:
The associated value

makeTransactional

public void makeTransactional()
Method to change the object state to transactional.

Specified by:
makeTransactional in interface StateManager

makeTransient

public void makeTransient(FetchPlanState state)
Method to change the object state to transient.

Specified by:
makeTransient in interface StateManager
Parameters:
state - Object containing the state of any fetchplan processing

detach

public void detach(FetchPlanState state)
Method to detach this object. If the object is detachable then it will be migrated to DETACHED state, otherwise will migrate to TRANSIENT. Used by "DetachAllOnCommit"/"DetachAllOnRollback"

Specified by:
detach in interface StateManager
Parameters:
state - State for the detachment process

detachCopy

public java.lang.Object detachCopy(FetchPlanState state)
Method to make detached copy of this instance If the object is detachable then the copy will be migrated to DETACHED state, otherwise will migrate the copy to TRANSIENT. Used by "ObjectManager.detachObjectCopy()".

Specified by:
detachCopy in interface StateManager
Parameters:
state - State for the detachment process
Returns:
the detached PersistenceCapable instance

getReferencedPC

public java.lang.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.

Specified by:
getReferencedPC in interface StateManager
Returns:
The referenced object (or null).

attach

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

Specified by:
attach in interface StateManager
Parameters:
embedded - Whether it is embedded

attachCopy

public java.lang.Object attachCopy(java.lang.Object obj,
                                   boolean embedded)
Method to attach a copy of the detached persistable instance and return the (attached) copy.

Specified by:
attachCopy in interface StateManager
Parameters:
obj - the detached persistable instance to be attached
embedded - Whether the object is stored embedded/serialised in another object
Returns:
The attached copy

deletePersistent

public void deletePersistent()
Method to delete the object from persistence.

Specified by:
deletePersistent in interface StateManager

becomingDeleted

public boolean becomingDeleted()
Whether this object is moving to a deleted state.

Specified by:
becomingDeleted in interface StateManager
Returns:
Whether the object will be moved into a deleted state during this operation

locate

public void locate()
Locate the object in the datastore.

Specified by:
locate in interface StateManager
Throws:
NucleusObjectNotFoundException - if the object doesnt exist.

nullifyFields

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

Specified by:
nullifyFields in interface StateManager

markForInheritanceValidation

public void markForInheritanceValidation()
Description copied from interface: StateManager
Mark the state manager as needing to validate the inheritance of the managed object existence before loading fields.

Specified by:
markForInheritanceValidation in interface StateManager

validate

public void validate()
Validates whether the persistence capable instance exists in the datastore. If the instance doesn't exist in the datastore, this method will fail raising a NucleusObjectNotFoundException. If the object is transactional then does nothing. If the object has unloaded (non-SCO, non-PK) fetch plan fields then fetches them. Else it checks the existence of the object in the datastore.

Specified by:
validate in interface StateManager

preStateChange

protected void preStateChange()
Method called before a change in state.

Specified by:
preStateChange in class AbstractStateManager

postStateChange

protected void postStateChange()
Method called after a change in state.

Specified by:
postStateChange in class AbstractStateManager

setStoringPC

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

Specified by:
setStoringPC in interface StateManager

unsetStoringPC

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

Specified by:
unsetStoringPC in interface StateManager

preSerialize

public void preSerialize(javax.jdo.spi.PersistenceCapable pc)
Guarantee that the serializable transactional and persistent fields are loaded into the instance. This method is called by the generated jdoPreSerialize method prior to serialization of the instance.

Parameters:
pc - the calling PersistenceCapable instance

flush

public void flush()
Flushes any outstanding changes to the object to the datastore. This will process :-

Specified by:
flush in interface StateManager

disconnectClone

protected boolean disconnectClone(javax.jdo.spi.PersistenceCapable pc)
Method to disconnect any cloned persistence capable objects from their StateManager.

Specified by:
disconnectClone in class AbstractStateManager
Parameters:
pc - The PersistenceCapable object
Returns:
Whether the object was disconnected.

disconnect

public void disconnect()
Disconnect the StateManager from the PersistenceManager and PC object.

Specified by:
disconnect in interface StateManager

registerTransactional

public void registerTransactional()
Registers the pc class in the cache

Specified by:
registerTransactional in interface StateManager

retrieveDetachState

public void retrieveDetachState(StateManager sm)
Convenience method to retrieve the detach state from the passed State Manager's object.

Specified by:
retrieveDetachState in interface StateManager
Parameters:
sm - The State Manager

resetDetachState

public void resetDetachState()
Convenience method to reset the detached state in the current object.

Specified by:
resetDetachState in interface StateManager

replacingDetachedState

public java.lang.Object[] replacingDetachedState(javax.jdo.spi.Detachable pc,
                                                 java.lang.Object[] currentState)
Method to update the "detached state" in the detached object to obtain the "detached state" from the detached object, or to reset it (to null).

Parameters:
pc - The PersistenceCapable beind updated
currentState - The current state values
Returns:
The detached state to assign to the object

dump

public void dump(java.io.PrintWriter out)
Utility to dump the contents of the StateManager.

Specified by:
dump in interface StateManager
Parameters:
out - PrintWriter to dump to

getObjectProvider

public ObjectProvider getObjectProvider()
Description copied from interface: StateManager
Accessor for the ObjectProvider.

Specified by:
getObjectProvider in interface StateManager
Returns:
The Object Provider for this StateManager


Copyright © 2011. All Rights Reserved.