Interface Transaction

  • All Known Subinterfaces:
    Transaction
    All Known Implementing Classes:
    TransactionImpl

    public interface Transaction
    The JDO Transaction interface is a sub-interface of the PersistenceManager that deals with options and completion of transactions under user control.

    Transaction options include whether optimistic concurrency control should be used for the current transaction, and whether values should be retained in JDO instances after transaction completion.

    Transaction completion methods have the same semantics as jakarta.transaction UserTransaction, and are valid only in the non-managed, non-distributed transaction environment.

    Version:
    0.1
    Author:
    Craig Russell
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void begin()
      Begin a transaction.
      void commit()
      Commit the current transaction.
      boolean getNontransactionalRead()
      If this flag is set to true, then queries and navigation are allowed without an active transaction
      boolean getOptimistic()
      Optimistic transactions do not hold data store locks until commit time.
      PersistenceManager getPersistenceManager()
      The Tranansaction instance is always associated with exactly one PersistenceManager.
      int getQueryTimeout()
      Gets the number of seconds to wait for a query statement to execute in the datastore associated with this Transaction instance
      boolean getRestoreValues()
      If true, at rollback time instances restore their field values.
      boolean getRetainValues()
      If true, at commit time instances retain their field values.
      jakarta.transaction.Synchronization getSynchronization()
      The user-specified Synchronization instance for this Transaction instance.
      int getUpdateTimeout()
      Gets the number of seconds to wait for an update statement to execute in the datastore associated with this Transaction instance
      boolean isActive()
      Returns whether there is a transaction currently active.
      void rollback()
      Roll back the current transaction.
      void setNontransactionalRead​(boolean flag)
      If this flag is set to true, then queries and navigation are allowed without an active transaction
      void setOptimistic​(boolean optimistic)
      Optimistic transactions do not hold data store locks until commit time.
      void setQueryTimeout​(int timeout)
      Sets the number of seconds to wait for a query statement to execute in the datastore associated with this Transaction instance
      void setRestoreValues​(boolean restoreValues)
      If true, at rollback instances restore their values and the instances transition to persistent-nontransactional.
      void setRetainValues​(boolean retainValues)
      If true, at commit instances retain their values and the instances transition to persistent-nontransactional.
      void setSynchronization​(jakarta.transaction.Synchronization sync)
      The user can specify a Synchronization instance to be notified on transaction completions.
      void setUpdateTimeout​(int timeout)
      Sets the number of seconds to wait for an update statement to execute in the datastore associated with this Transaction instance
    • Method Detail

      • begin

        void begin()
        Begin a transaction. The type of transaction is determined by the setting of the Optimistic flag.
        Throws:
        JDOUserException - if a distributed transaction XAResource is assigned to this Transaction
        See Also:
        setOptimistic(boolean), getOptimistic()
      • commit

        void commit()
        Commit the current transaction.
      • rollback

        void rollback()
        Roll back the current transaction.
      • isActive

        boolean isActive()
        Returns whether there is a transaction currently active.
        Returns:
        boolean
      • setRetainValues

        void setRetainValues​(boolean retainValues)
        If true, at commit instances retain their values and the instances transition to persistent-nontransactional.

        Setting this flag also sets the NontransactionalRead flag.

        Parameters:
        retainValues - the value of the retainValues property
      • getRetainValues

        boolean getRetainValues()
        If true, at commit time instances retain their field values.
        Returns:
        the value of the retainValues property
      • setRestoreValues

        void setRestoreValues​(boolean restoreValues)
        If true, at rollback instances restore their values and the instances transition to persistent-nontransactional.
        Parameters:
        restoreValues - the value of the restoreValues property
      • getRestoreValues

        boolean getRestoreValues()
        If true, at rollback time instances restore their field values.
        Returns:
        the value of the restoreValues property
      • setOptimistic

        void setOptimistic​(boolean optimistic)
        Optimistic transactions do not hold data store locks until commit time.
        Parameters:
        optimistic - the value of the Optimistic flag.
      • getOptimistic

        boolean getOptimistic()
        Optimistic transactions do not hold data store locks until commit time.
        Returns:
        the value of the Optimistic property.
      • setNontransactionalRead

        void setNontransactionalRead​(boolean flag)
        If this flag is set to true, then queries and navigation are allowed without an active transaction
        Parameters:
        flag - the value of the nontransactionalRead property.
      • getNontransactionalRead

        boolean getNontransactionalRead()
        If this flag is set to true, then queries and navigation are allowed without an active transaction
        Returns:
        the value of the nontransactionalRead property.
      • setSynchronization

        void setSynchronization​(jakarta.transaction.Synchronization sync)
        The user can specify a Synchronization instance to be notified on transaction completions. The beforeCompletion method is called prior to flushing instances to the data store.

        The afterCompletion method is called after performing the data store commit operation.

        Parameters:
        sync - the Synchronization instance to be notified; null for none
      • getSynchronization

        jakarta.transaction.Synchronization getSynchronization()
        The user-specified Synchronization instance for this Transaction instance.
        Returns:
        the user-specified Synchronization instance.
      • setQueryTimeout

        void setQueryTimeout​(int timeout)
        Sets the number of seconds to wait for a query statement to execute in the datastore associated with this Transaction instance
        Parameters:
        timeout - new timout value in seconds; zero means unlimited
      • getQueryTimeout

        int getQueryTimeout()
        Gets the number of seconds to wait for a query statement to execute in the datastore associated with this Transaction instance
        Returns:
        timout value in seconds; zero means unlimited
      • setUpdateTimeout

        void setUpdateTimeout​(int timeout)
        Sets the number of seconds to wait for an update statement to execute in the datastore associated with this Transaction instance
        Parameters:
        timeout - new timout value in seconds; zero means unlimited
      • getUpdateTimeout

        int getUpdateTimeout()
        Gets the number of seconds to wait for an update statement to execute in the datastore associated with this Transaction instance
        Returns:
        timout value in seconds; zero means unlimited
      • getPersistenceManager

        PersistenceManager getPersistenceManager()
        The Tranansaction instance is always associated with exactly one PersistenceManager.
        Returns:
        the PersistenceManager for this Transaction instance