Class JdbcTxManagerImpl

  • All Implemented Interfaces:
    JdbcTxManager

    public class JdbcTxManagerImpl
    extends Object
    implements JdbcTxManager
    Implementation of a transaction manager, which is responsible for handling a Connection object which is placed into ThreadLocal.

    It is responsible for fetching Connection objects from a DataSource, and setting them up so that they can be transactional (autoCommit --> false).

    It also can be used to rollback programatically an existing transaction.

    • Constructor Detail

      • JdbcTxManagerImpl

        @Inject
        public JdbcTxManagerImpl​(DataSource dataSource)
    • Method Detail

      • isTransaction

        public boolean isTransaction()
        Description copied from interface: JdbcTxManager
        Checks whether the current connection is not null and autocomit is set to false.
        Specified by:
        isTransaction in interface JdbcTxManager
        Returns:
      • isConnection

        public boolean isConnection()
        Description copied from interface: JdbcTxManager
        Checks if the current connection is null.
        Specified by:
        isConnection in interface JdbcTxManager
        Returns:
      • newConnection

        public void newConnection​(boolean autoCommit)
        Description copied from interface: JdbcTxManager
        N.B. DO NOT USE THIS METHOD DIRECTLY. It is only to be used by the TransactionalMethodInterceptor and the RepositoryConnectionMethodInterceptor Makes a Connection object available from the getConnection() method with either autocomit set to true or false.
        Specified by:
        newConnection in interface JdbcTxManager
        Parameters:
        autoCommit - automatically commits after each execute. Set to false to use transactions.
      • commit

        public void commit()
        Description copied from interface: JdbcTxManager
        Commits the current connection Requires that the existing connection was created with autocommit set to false.
        Specified by:
        commit in interface JdbcTxManager
      • rollback

        public void rollback()
        Description copied from interface: JdbcTxManager
        Rollbacks the current connection
        Specified by:
        rollback in interface JdbcTxManager
      • cleanUp

        public void cleanUp()
        Description copied from interface: JdbcTxManager
        Closes the connection and removes the connection from the thread local
        Specified by:
        cleanUp in interface JdbcTxManager
      • setRollbackOnly

        public void setRollbackOnly()
        marks the transaction to be rollbacked
        Specified by:
        setRollbackOnly in interface JdbcTxManager
      • trace

        public void trace​(String message)
        logs a debug message with the current transaction object
        Specified by:
        trace in interface JdbcTxManager
        Parameters:
        message -