Class SQLStateManager

    • Field Detail

      • hiddenValues

        public ArrayList hiddenValues
        Array of Object.
    • Constructor Detail

      • SQLStateManager

        public SQLStateManager​(PersistenceStore store,
                               ClassDesc persistenceConfig)
        Construct a new SQLStateManager so that it locks or does not lock as per whether or not it is used in a managed environment.
    • Method Detail

      • initialize

        public void initialize​(boolean persistentInDB)
        Description copied from interface: StateManager
        State initialization
        Specified by:
        initialize in interface StateManager
        Parameters:
        persistentInDB - true if object is persistent in DB
      • setPresenceMaskBit

        public void setPresenceMaskBit​(int index)
        Description copied from interface: StateManager
        Marks field with this index as present.
        Specified by:
        setPresenceMaskBit in interface StateManager
        Parameters:
        index - - the field number.
      • getPresenceMaskBit

        public boolean getPresenceMaskBit​(int index)
        Description copied from interface: StateManager
        Returns true if field with this index is present in the instance.
        Specified by:
        getPresenceMaskBit in interface StateManager
      • getSetMaskBit

        public boolean getSetMaskBit​(int index)
      • getHiddenValue

        public Object getHiddenValue​(int index)
        Description copied from interface: StateManager
        Returns value for a hidden field. This method expects index to be negative for hidden fields.
        Specified by:
        getHiddenValue in interface StateManager
        Parameters:
        index - - the hidden field index.
      • setHiddenValue

        public void setHiddenValue​(int index,
                                   Object value)
        Description copied from interface: StateManager
        Sets value for a hidden field. This method expects index to be negative for hidden fields.
        Specified by:
        setHiddenValue in interface StateManager
        Parameters:
        index - - the hidden field index.
        value - - new value.
      • makePersistent

        public void makePersistent​(PersistenceManager pm,
                                   Object pc)
        Prepares the associated object to be stored in the datastore. This method is called by PersistenceManager.makePersistent(). Thread synchronization is done in the persistence manager.
        Specified by:
        makePersistent in interface StateManager
      • deletePersistent

        public void deletePersistent()
        Prepares the associated object for delete. This method is called by PersistenceManager.deletePersistent(). After nullifying the relationship fields, the instance transitions to deleted state.
        Specified by:
        deletePersistent in interface StateManager
      • updatePersistent

        public void updatePersistent​(StateManager next)
        Stores the associated object in the datastore. This method is called by PersistenceManager.beforeCompletion() on flush/commit. The specified state manager argument is used to determine whether the actual instance should be flushed immediately or whether batch update is possible.
        Specified by:
        updatePersistent in interface StateManager
        Parameters:
        next - Next state manager in the transaction cache.
      • incrementVersion

        public void incrementVersion()
        Increments the version fields for this state manager. Instances mapped to multiple tables have got a version field for each table.
      • hasVersionConsistency

        public boolean hasVersionConsistency()
        Description copied from interface: StateManager
        Returns true, if the managed instance has Version Consistency.
        Specified by:
        hasVersionConsistency in interface StateManager
        Returns:
        True, if the managed object has Version Consistency.
      • verifyPersistent

        public boolean verifyPersistent()
        Description copied from interface: StateManager
        Verify that an instance set up with Version consistency is not modified in a parallel transaction.
        Specified by:
        verifyPersistent in interface StateManager
        Returns:
        false if the instance is persistent clean and modified by a parallel transaction, true otherwise.
      • setVerificationFailed

        public void setVerificationFailed()
        Description copied from interface: StateManager
        Marks that this state manager has failed version consistency validation.
        Specified by:
        setVerificationFailed in interface StateManager
      • isVerificationFailed

        public boolean isVerificationFailed()
        Description copied from interface: StateManager
        Returns, if this state manager has failed version consistency validation.
        Specified by:
        isVerificationFailed in interface StateManager
        Returns:
        True, if this state manager is marked as failed.
      • refreshPersistent

        public void refreshPersistent()
        Description copied from interface: StateManager
        ... The PersistenceManager calls this method to refresh the state of the StateManager from the database.
        Specified by:
        refreshPersistent in interface StateManager
      • prepareToUpdatePhaseI

        public void prepareToUpdatePhaseI()
        PersistenceManager calls this method to prepare a persistent object for update. This is required for foreign fields only as they could reference "regular" JDK Collections vs. SCO Collections. Such process has the side-effect of causing more objects to be registered with the transaction cache.
        Specified by:
        prepareToUpdatePhaseI in interface StateManager
      • prepareToUpdatePhaseII

        public void prepareToUpdatePhaseII​(HashSet phase3sms)
        This is the second phase of the commit processing. It populates phase3sms with all the autopersistent instances that are no longer reachable from a persistent instance.
        Specified by:
        prepareToUpdatePhaseII in interface StateManager
        Parameters:
        phase3sms - List containing autopersistent instances that are no longer reachable from a persistent instance.
      • prepareToUpdatePhaseIII

        public void prepareToUpdatePhaseIII()
        This is the third phase of commit processing. It sets up the delete dependencies among all the autopersistent instances that have been flushed to the database.
        Specified by:
        prepareToUpdatePhaseIII in interface StateManager
      • release

        public void release()
        Description copied from interface: StateManager
        Release references in the StateManager to the persistent instance, ObjectId, and PersistenceManager.
        Specified by:
        release in interface StateManager
      • isProcessed

        public boolean isProcessed()
        Description copied from interface: StateManager
        ... The PersistenceManager calls this method to verify that corresponding object has been flushed to the database
        Specified by:
        isProcessed in interface StateManager
        Returns:
        true if persistentObject has been flushed to db
      • flushed

        public void flushed()
        Description copied from interface: StateManager
        ... The PersistenceManager calls this method to inform the StateManager that the flush processing is completed.
        Specified by:
        flushed in interface StateManager
      • commit

        public void commit​(boolean retainValues)
        Description copied from interface: StateManager
        ... The PersistenceManager calls this method to inform the StateManager that the transaction has been committed.
        Specified by:
        commit in interface StateManager
      • rollback

        public void rollback​(boolean retainValues)
        Description copied from interface: StateManager
        ... The PersistenceManager calls this method to inform the StateManager that the transaction has been rolled back.
        Specified by:
        rollback in interface StateManager
      • isBeforeImageRequired

        public boolean isBeforeImageRequired()
      • copyFields

        public void copyFields​(StateManager source)
        Description copied from interface: StateManager
        Copies field values from source to this StateManager's fields.
        Specified by:
        copyFields in interface StateManager
        Parameters:
        source - StateManager from which field values are copied into this instance.
      • resolveDependencies

        public void resolveDependencies()
        Resolves the dependencies for the instances waiting for this state manager. Dependencies are registered instantly during the course of the transaction. For this reason, the introduced dependencies must be checked, if they are still valid at commit/flush. E.g. remove dependencies introduced on relationship removal are only valid, if the removed instance is deleted.

        This method checks the dependencies for all instances waiting for the current state manager to be flushed to the store.

        Specified by:
        resolveDependencies in interface StateManager
      • setFlags

        public byte setFlags​(byte flags)
        ...
        Specified by:
        setFlags in interface StateManager
      • loadForRead

        public void loadForRead()
        Triggers the state transition for READ and registers the instance in the transaction cache.
        Specified by:
        loadForRead in interface StateManager
      • loadForUpdate

        public void loadForUpdate()
        Triggers the state transition for WRITE and registers the instance in the transaction cache. Prepares all DFG fields for update.
        Specified by:
        loadForUpdate in interface StateManager
      • replaceCollection

        public void replaceCollection​(ForeignFieldDesc ff,
                                      Collection c)
        This method serves two purposes: 1. If the field value is null or contains a non-SCOCollection instance, it creates a new SCOCollection and populates with elements in c. 2. If the field value is a SCOCollection instance, then if it is deferred, it calls applyDeferredUpdates on the collection passing in c. Otherwise, it clears the collection and repopulates with elements in c.
      • getCurrentState

        protected LifeCycleState getCurrentState()
        For test purposes
      • needsRegisterWithVersionConsistencyCache

        public boolean needsRegisterWithVersionConsistencyCache()
        Specified by:
        needsRegisterWithVersionConsistencyCache in interface StateManager
        Returns:
        True, if this instance is persistent, transactional, not new, not dirty, and not deleted; false otherwise.
      • needsUpdateInVersionConsistencyCache

        public boolean needsUpdateInVersionConsistencyCache()
        Specified by:
        needsUpdateInVersionConsistencyCache in interface StateManager
        Returns:
        True, if this instance should be synchronized with the version consistency cache; false otherwise.
      • setBooleanField

        public boolean setBooleanField​(int fieldNumber,
                                       boolean value)
        Specified by:
        setBooleanField in interface StateManager
      • setBooleanArrayField

        public boolean[] setBooleanArrayField​(int fieldNumber,
                                              boolean[] value)
        Specified by:
        setBooleanArrayField in interface StateManager
      • setByteField

        public byte setByteField​(int fieldNumber,
                                 byte value)
        Specified by:
        setByteField in interface StateManager
      • setByteArrayField

        public byte[] setByteArrayField​(int fieldNumber,
                                        byte[] value)
        Specified by:
        setByteArrayField in interface StateManager
      • setShortField

        public short setShortField​(int fieldNumber,
                                   short value)
        Specified by:
        setShortField in interface StateManager
      • setShortArrayField

        public short[] setShortArrayField​(int fieldNumber,
                                          short[] value)
        Specified by:
        setShortArrayField in interface StateManager
      • setIntField

        public int setIntField​(int fieldNumber,
                               int value)
        Specified by:
        setIntField in interface StateManager
      • setIntArrayField

        public int[] setIntArrayField​(int fieldNumber,
                                      int[] value)
        Specified by:
        setIntArrayField in interface StateManager
      • setLongField

        public long setLongField​(int fieldNumber,
                                 long value)
        Specified by:
        setLongField in interface StateManager
      • setLongArrayField

        public long[] setLongArrayField​(int fieldNumber,
                                        long[] value)
        Specified by:
        setLongArrayField in interface StateManager
      • setCharField

        public char setCharField​(int fieldNumber,
                                 char value)
        Specified by:
        setCharField in interface StateManager
      • setCharArrayField

        public char setCharArrayField​(int fieldNumber,
                                      char value)
        Specified by:
        setCharArrayField in interface StateManager
      • setFloatField

        public float setFloatField​(int fieldNumber,
                                   float value)
        Specified by:
        setFloatField in interface StateManager
      • setFloatArrayField

        public float[] setFloatArrayField​(int fieldNumber,
                                          float[] value)
        Specified by:
        setFloatArrayField in interface StateManager
      • setDoubleField

        public double setDoubleField​(int fieldNumber,
                                     double value)
        Specified by:
        setDoubleField in interface StateManager
      • setDoubleArrayField

        public double[] setDoubleArrayField​(int fieldNumber,
                                            double[] value)
        Specified by:
        setDoubleArrayField in interface StateManager
      • setObjectField

        public Object setObjectField​(int fieldNumber,
                                     Object value)
        This method sets object fields, e.g. relationship fields.
        Specified by:
        setObjectField in interface StateManager
      • testIsLoaded

        public boolean testIsLoaded​(int fieldNumber)
        Description copied from interface: TestStateManager
        This method is used to test if a field identified by fieldNumber is loaded in memory. It returns true is the field is loaded and false otehrwise.
        Specified by:
        testIsLoaded in interface TestStateManager
      • testIsLoaded

        public boolean testIsLoaded​(String fieldName)
        Description copied from interface: TestStateManager
        This method is used to test if a field identified by fieldName is loaded in memory. It returns true is the field is loaded and false, otehrwise.
        Specified by:
        testIsLoaded in interface TestStateManager
      • testIsAutoPersistent

        public boolean testIsAutoPersistent()
        Description copied from interface: TestStateManager
        This method is used to determine if an instance is in the autopersistent state. It returns true if the instance is autopersistence and false otherwise.
        Specified by:
        testIsAutoPersistent in interface TestStateManager
      • markNotRegistered

        public void markNotRegistered()
        Marks this instance needs to require registering with the global (weak) cache at rollback if it transitions to persistent state. Used for replacing a deleted instance with the newly persistent with the same object id.
        Specified by:
        markNotRegistered in interface StateManager
      • markVerifyAtDeregister

        public void markVerifyAtDeregister()
        Marks this instance as needs to be verified at the time it is removed from the global (weak) cache at rollback if it transitions to transient state.
        Specified by:
        markVerifyAtDeregister in interface StateManager
      • markReplacement

        public void markReplacement()
        Marks this instance as a replacement for a deleted instance with the same ObjectId.
        Specified by:
        markReplacement in interface StateManager
      • getLock

        public void getLock()
        Lock this instance.
        Specified by:
        getLock in interface StateManager
      • isValid

        public boolean isValid()
        Return value for valid flag.
        Specified by:
        isValid in interface StateManager
      • setValid

        public void setValid()
        Mark this StateManager as valid. Called before returning from getObjectById.
        Specified by:
        setValid in interface StateManager