Interface PersistenceManager

    • Method Detail

      • setFlags

        void setFlags​(Object pc,
                      byte flags)
      • getFlags

        byte getFlags​(Object pc)
      • setField

        void setField​(Object pc,
                      int fieldNumber,
                      Object value)
      • getField

        Object getField​(Object pc,
                        int fieldNumber)
      • clearFields

        void clearFields​(Object pc)
      • retrieve

        Object retrieve​(RetrieveDesc action,
                        ValueFetcher parameters)
        Executes the given retrieve descriptor. The result is a collection unless an aggregate query was specified. In most cases the query result is a collection of persistent objects. In case of a projection on a local field the collection holds objects of that type. For aggregate queries the result is a single object, which type was defined by the caller.
        Parameters:
        action - The retrieve descriptor.
        parameters - The input parameters for the query.
        Returns:
        A collection of (persistent) objects unless an aggregate query was specified.
      • retrieve

        Object retrieve​(RetrieveDesc action)
        Executes the given retrieve descriptor. The result is a collection unless an aggregate query was specified. In most cases the query result is a collection of persistent objects. In case of a projection on a local field the collection holds objects of that type. For aggregate queries the result is a single object, which type was defined by the caller.
        Parameters:
        action - The retrieve descriptor.
        Returns:
        A collection of (persistent) objects unless an aggregate query was specified.
      • getRetrieveDesc

        RetrieveDesc getRetrieveDesc​(Class classType)
        Return a RetrieveDesc given a Class object.
      • getRetrieveDesc

        RetrieveDesc getRetrieveDesc​(String fieldName,
                                     Class classType)
        Return a RetrieveDesc for a foreign field (relationship) given the Class object for the parent class.
      • afterCompletion

        void afterCompletion​(int status)
        Called by Transaction commit() or rollback() cleans up transactional cache
        Parameters:
        status - jakarta.transaction.Status
      • beforeCompletion

        void beforeCompletion()
        Called by Transaction commit() Loops through transactional cache and calls PersistentStore.updatePersistent() on each instance
      • internalFlush

        void internalFlush()
        Called by Query in pessimistic transaction to flush changes to the database
      • registerInstance

        void registerInstance​(StateManager sm,
                              Object oid,
                              boolean throwDuplicateException,
                              boolean forceRegister)
        Called by StateManager to register new instance. This method will throw an JDOUserException if throwDuplicateException is true and the object being registered already exists in the pm cache.
      • registerInstance

        void registerInstance​(StateManager sm,
                              Object oid)
        Called by StateManager to register persistent instance at the rollback if it was removed from the global (weak) cache as the result of the replace operation.
      • deregisterInstance

        void deregisterInstance​(Object oid)
        Deregister an instance.
      • deregisterInstance

        void deregisterInstance​(Object oid,
                                StateManager sm)
        Deregister an instance with this object Id, only if it holds the same instance.
      • notifyStatusChange

        void notifyStatusChange​(boolean isActive)
        For Transaction to notify PersistenceManager that status is changed
      • notifyOptimistic

        void notifyOptimistic​(boolean optimistic)
        For Transaction to notify PersistenceManager that optimistic flag is changed
      • isOptimisticTransaction

        boolean isOptimisticTransaction()
        Returns true if associated transaction is optimistic
      • notifyNontransactionalRead

        void notifyNontransactionalRead​(boolean nontransactionalRead)
        For Transaction to notify PersistenceManager that optimistic flag is changed
      • isNontransactionalRead

        boolean isNontransactionalRead()
        Returns true if nontransactionalRead flag is set to true.
      • isActiveTransaction

        boolean isActiveTransaction()
        Returns true if associated transaction is active
      • newSCOInstanceInternal

        Object newSCOInstanceInternal​(Class type,
                                      Object owner,
                                      String fieldName)
        Called by newSCOInstance from the public interface or internally by the runtime Will not result in marking field as dirty Returns a new Second Class Object instance of the type specified,
        Parameters:
        type - Class of the new SCO instance
        owner - the owner to notify upon changes
        fieldName - the field to notify upon changes
        Returns:
        the object of the class type
      • newCollectionInstanceInternal

        Object newCollectionInstanceInternal​(Class type,
                                             Object owner,
                                             String fieldName,
                                             Class elementType,
                                             boolean allowNulls,
                                             int initialSize)
        Called by newCollectionInstance from the public interface or internally by the runtime Will not result in marking field as dirty
        Parameters:
        type - Class of the new SCO instance
        owner - the owner to notify upon changes
        fieldName - the field to notify upon changes
        elementType - the element types allowed
        allowNulls - true if allowed
        initialSize - initial size of the Collection
        Returns:
        the object of the class type
      • acquireFieldUpdateLock

        void acquireFieldUpdateLock()
        Serialize field updates
      • releaseFieldUpdateLock

        void releaseFieldUpdateLock()
        Allow other threads to update fields
      • acquireShareLock

        void acquireShareLock()
        Acquires a share lock from the persistence manager. This method will put the calling thread to sleep if another thread is holding the exclusive lock.
      • releaseShareLock

        void releaseShareLock()
        Releases the share lock and notify any thread waiting to get an exclusive lock. Note that every releaseShareLock() call needs to be preceeded by an acquireShareLock() call.
      • acquireExclusiveLock

        void acquireExclusiveLock()
        Acquires an exclusive lock from the persistence manager. By acquiring an exclusive lock, a thread is guaranteed to have exclusive right to the persistence runtime meaning no other threads can perform any operation in the runtime.
      • releaseExclusiveLock

        void releaseExclusiveLock()
        Release the exclusive lock and notify any thread waiting to get an exclusive or share lock. Note that every releaseShareLock() call needs to be preceeded by an acquireExclusiveLock() call.
      • forceClose

        void forceClose()
        Force to close the persistence manager. Called by TransactionImpl.afterCompletion in case of the CMT transaction and the status value passed to the method cannot be resolved.
      • findOrCreateStateManager

        StateManager findOrCreateStateManager​(Object oid,
                                              Class pcClass)
        Returns StateManager instance for this Object Id.
        Parameters:
        oid - the ObjectId to look up.
        pcClass - the expected Class type of the new PC instance.
      • acquireCacheLock

        void acquireCacheLock()
        Lock cache for getObjectById and result processing synchronization.
      • releaseCacheLock

        void releaseCacheLock()
        Release cache lock.
      • initializeFromVersionConsistencyCache

        boolean initializeFromVersionConsistencyCache​(StateManager sm)
        Looks up the given instance in the Version Consistency cache and if found, populates it from the cached values.
        Parameters:
        sm - Instance to be looked up in the version consistency cache. If found, it is populated with values from the cache.
        Returns:
        true if the sm was found and populated, false otherwise.