Class JDOTransaction

  • All Implemented Interfaces:
    javax.jdo.Transaction

    public class JDOTransaction
    extends Object
    implements javax.jdo.Transaction
    Wrapper for the transaction for use by JDO.
    • Constructor Detail

      • JDOTransaction

        public JDOTransaction​(JDOPersistenceManager pm,
                              org.datanucleus.transaction.Transaction tx)
        Constructor
        Parameters:
        pm - The JDO PersistenceManager
        tx - The real transaction
    • Method Detail

      • getPersistenceManager

        public JDOPersistenceManager getPersistenceManager()
        Accessor for the JDO PersistenceManager
        Specified by:
        getPersistenceManager in interface javax.jdo.Transaction
        Returns:
        The JDO PM
      • isActive

        public boolean isActive()
        Accessor for whether the transaction is active
        Specified by:
        isActive in interface javax.jdo.Transaction
        Returns:
        Whether it is active
      • begin

        public void begin()
        Method to start the transaction.
        Specified by:
        begin in interface javax.jdo.Transaction
      • commit

        public void commit()
        Method to commit the transaction.
        Specified by:
        commit in interface javax.jdo.Transaction
      • rollback

        public void rollback()
        Method to rollback the transaction
        Specified by:
        rollback in interface javax.jdo.Transaction
      • getNontransactionalRead

        public boolean getNontransactionalRead()
        Accessor for nontransactionalRead setting
        Specified by:
        getNontransactionalRead in interface javax.jdo.Transaction
        Returns:
        The setting for nontransactionalRead
      • getNontransactionalWrite

        public boolean getNontransactionalWrite()
        Accessor for nontransactionalWrite setting
        Specified by:
        getNontransactionalWrite in interface javax.jdo.Transaction
        Returns:
        The setting for nontransactionalWrite
      • getNontransactionalWriteAutoCommit

        public boolean getNontransactionalWriteAutoCommit()
        Accessor for nontransactionalWrite setting
        Returns:
        The setting for nontransactionalWrite
      • getOptimistic

        public boolean getOptimistic()
        Accessor for optimistic setting
        Specified by:
        getOptimistic in interface javax.jdo.Transaction
        Returns:
        The setting for optimistic
      • getRestoreValues

        public boolean getRestoreValues()
        Accessor for restoreValues setting
        Specified by:
        getRestoreValues in interface javax.jdo.Transaction
        Returns:
        The setting for restoreValues
      • getRetainValues

        public boolean getRetainValues()
        Accessor for retainValues setting
        Specified by:
        getRetainValues in interface javax.jdo.Transaction
        Returns:
        The setting for retainValues
      • getRollbackOnly

        public boolean getRollbackOnly()
        Accessor for whether to allow rollback only
        Specified by:
        getRollbackOnly in interface javax.jdo.Transaction
        Returns:
        Whether to allow rollback only
      • getSynchronization

        public javax.transaction.Synchronization getSynchronization()
        Accessor for the synchronization (if any)
        Specified by:
        getSynchronization in interface javax.jdo.Transaction
        Returns:
        The synchronization
      • setNontransactionalRead

        public void setNontransactionalRead​(boolean flag)
        Mutator for the nontransactionalRead setting.
        Specified by:
        setNontransactionalRead in interface javax.jdo.Transaction
        Parameters:
        flag - Whether to allow nontransactional read
      • setNontransactionalWrite

        public void setNontransactionalWrite​(boolean flag)
        Mutator for the nontransactionalWrite setting.
        Specified by:
        setNontransactionalWrite in interface javax.jdo.Transaction
        Parameters:
        flag - Whether to allow nontransactional write
      • setNontransactionalWriteAutoCommit

        public void setNontransactionalWriteAutoCommit​(boolean flag)
        Mutator for the nontransactionalWrite auto-commit setting.
        Parameters:
        flag - Whether to auto-commit any non-tx writes
      • setOptimistic

        public void setOptimistic​(boolean opt)
        Mutator for the optimistic setting
        Specified by:
        setOptimistic in interface javax.jdo.Transaction
        Parameters:
        opt - Whether to use optimistic transactions
      • setRestoreValues

        public void setRestoreValues​(boolean restore)
        Mutator for the restore values setting
        Specified by:
        setRestoreValues in interface javax.jdo.Transaction
        Parameters:
        restore - Whether to restore values
      • setRetainValues

        public void setRetainValues​(boolean retain)
        Mutator for the retain values setting
        Specified by:
        setRetainValues in interface javax.jdo.Transaction
        Parameters:
        retain - Whether to retain values after commit
      • setRollbackOnly

        public void setRollbackOnly()
        Mutator for the rollback-only setting
        Specified by:
        setRollbackOnly in interface javax.jdo.Transaction
      • setSynchronization

        public void setSynchronization​(javax.transaction.Synchronization synch)
        Mutator for the Synchronisation
        Specified by:
        setSynchronization in interface javax.jdo.Transaction
        Parameters:
        synch - The Synchronisation
      • setIsolationLevel

        public void setIsolationLevel​(String level)
        Mutator for the isolation level.
        Specified by:
        setIsolationLevel in interface javax.jdo.Transaction
        Parameters:
        level - The level
        Throws:
        javax.jdo.JDOUserException - if the required level is not supported.
      • getIsolationLevel

        public String getIsolationLevel()
        Accessor for the current isolation level.
        Specified by:
        getIsolationLevel in interface javax.jdo.Transaction
        Returns:
        The isolation level.
      • setSavepoint

        public void setSavepoint​(String name)
        Method to mark the current point as a savepoint with the provided name.
        Parameters:
        name - Name of the savepoint.
        Throws:
        UnsupportedOperationException - if the underlying datastore doesn't support savepoints
        IllegalStateException - if no name is provided
      • releaseSavepoint

        public void releaseSavepoint​(String name)
        Method to mark the current point as a savepoint with the provided name.
        Parameters:
        name - Name of the savepoint.
        Throws:
        UnsupportedOperationException - if the underlying datastore doesn't support savepoints
        IllegalStateException - if no name is provided, or the name doesn't correspond to a known savepoint
      • rollbackToSavepoint

        public void rollbackToSavepoint​(String name)
        Method to mark the current point as a savepoint with the provided name.
        Parameters:
        name - Name of the savepoint.
        Throws:
        UnsupportedOperationException - if the underlying datastore doesn't support savepoints
        IllegalStateException - if no name is provided, or the name doesn't correspond to a known savepoint
      • assertNotCommitting

        protected void assertNotCommitting()
        Throw an Exception if the underlying transaction is currently committing.
      • assertNotInUse

        protected void assertNotInUse()
        Asserts that the transaction is not in use.
      • getSerializeRead

        public Boolean getSerializeRead()
        Accessor for whether to serialise any read objects in this transaction.
        Specified by:
        getSerializeRead in interface javax.jdo.Transaction
        Returns:
        The setting for whether to serialise any read objects
      • setSerializeRead

        public void setSerializeRead​(Boolean serialize)
        Mutator for whether to serialise any read objects.
        Specified by:
        setSerializeRead in interface javax.jdo.Transaction
        Parameters:
        serialize - Whether to serialise any read objects in this transaction
      • setOption

        public void setOption​(String option,
                              int value)
        Convenience accessor for setting a transaction option.
        Parameters:
        option - option name
        value - The value
      • setOption

        public void setOption​(String option,
                              boolean value)
        Convenience accessor for setting a transaction option.
        Parameters:
        option - option name
        value - The value
      • setOption

        public void setOption​(String option,
                              String value)
        Convenience accessor for setting a transaction option.
        Parameters:
        option - option name
        value - The value
      • registerEventListener

        public void registerEventListener​(org.datanucleus.transaction.TransactionEventListener listener)
        Method to register a listener for transaction events.
        Parameters:
        listener - The listener
      • deregisterEventListener

        public void deregisterEventListener​(org.datanucleus.transaction.TransactionEventListener listener)
        Method to deregister a listener for transaction events.
        Parameters:
        listener - The listener to remove