Class JDOTransaction

  • All Implemented Interfaces:
    javax.jdo.Transaction

    public class JDOTransaction
    extends java.lang.Object
    implements javax.jdo.Transaction
    Wrapper for the transaction for use by JDO.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) JDOPersistenceManager pm
      JDO PersistenceManager.
      (package private) org.datanucleus.transaction.Transaction tx
      The underlying transaction
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void assertNotCommitting()
      Throw an Exception if the underlying transaction is currently committing.
      protected void assertNotInUse()
      Asserts that the transaction is not in use.
      void begin()
      Method to start the transaction.
      void commit()
      Method to commit the transaction.
      void deregisterEventListener​(org.datanucleus.transaction.TransactionEventListener listener)
      Method to deregister a listener for transaction events.
      java.lang.String getIsolationLevel()
      Accessor for the current isolation level.
      boolean getNontransactionalRead()
      Accessor for nontransactionalRead setting
      boolean getNontransactionalWrite()
      Accessor for nontransactionalWrite setting
      boolean getNontransactionalWriteAutoCommit()
      Accessor for nontransactionalWrite setting
      boolean getOptimistic()
      Accessor for optimistic setting
      JDOPersistenceManager getPersistenceManager()
      Accessor for the JDO PersistenceManager
      boolean getRestoreValues()
      Accessor for restoreValues setting
      boolean getRetainValues()
      Accessor for retainValues setting
      boolean getRollbackOnly()
      Accessor for whether to allow rollback only
      java.lang.Boolean getSerializeRead()
      Accessor for whether to serialise any read objects in this transaction.
      javax.transaction.Synchronization getSynchronization()
      Accessor for the synchronization (if any)
      boolean isActive()
      Accessor for whether the transaction is active
      void registerEventListener​(org.datanucleus.transaction.TransactionEventListener listener)
      Method to register a listener for transaction events.
      void releaseSavepoint​(java.lang.String name)
      Method to mark the current point as a savepoint with the provided name.
      void rollback()
      Method to rollback the transaction
      void rollbackToSavepoint​(java.lang.String name)
      Method to mark the current point as a savepoint with the provided name.
      void setIsolationLevel​(java.lang.String level)
      Mutator for the isolation level.
      void setNontransactionalRead​(boolean flag)
      Mutator for the nontransactionalRead setting.
      void setNontransactionalWrite​(boolean flag)
      Mutator for the nontransactionalWrite setting.
      void setNontransactionalWriteAutoCommit​(boolean flag)
      Mutator for the nontransactionalWrite auto-commit setting.
      void setOptimistic​(boolean opt)
      Mutator for the optimistic setting
      void setOption​(java.lang.String option, boolean value)
      Convenience accessor for setting a transaction option.
      void setOption​(java.lang.String option, int value)
      Convenience accessor for setting a transaction option.
      void setOption​(java.lang.String option, java.lang.String value)
      Convenience accessor for setting a transaction option.
      void setRestoreValues​(boolean restore)
      Mutator for the restore values setting
      void setRetainValues​(boolean retain)
      Mutator for the retain values setting
      void setRollbackOnly()
      Mutator for the rollback-only setting
      void setSavepoint​(java.lang.String name)
      Method to mark the current point as a savepoint with the provided name.
      void setSerializeRead​(java.lang.Boolean serialize)
      Mutator for whether to serialise any read objects.
      void setSynchronization​(javax.transaction.Synchronization synch)
      Mutator for the Synchronisation
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • tx

        org.datanucleus.transaction.Transaction tx
        The underlying transaction
    • 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​(java.lang.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 java.lang.String getIsolationLevel()
        Accessor for the current isolation level.
        Specified by:
        getIsolationLevel in interface javax.jdo.Transaction
        Returns:
        The isolation level.
      • setSavepoint

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

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

        public void rollbackToSavepoint​(java.lang.String name)
        Method to mark the current point as a savepoint with the provided name.
        Parameters:
        name - Name of the savepoint.
        Throws:
        java.lang.UnsupportedOperationException - if the underlying datastore doesn't support savepoints
        java.lang.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 java.lang.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​(java.lang.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​(java.lang.String option,
                              int value)
        Convenience accessor for setting a transaction option.
        Parameters:
        option - option name
        value - The value
      • setOption

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

        public void setOption​(java.lang.String option,
                              java.lang.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