Class ManagedTransaction

  • All Implemented Interfaces:
    Transaction

    public class ManagedTransaction
    extends java.lang.Object
    implements Transaction
    Transaction that lets the container manage the full lifecycle of the transaction. Delays connection retrieval until getConnection() is called. Ignores all commit or rollback requests. By default, it closes the connection but can be configured not to do it.
    See Also:
    ManagedTransactionFactory
    • Field Detail

      • log

        private static final Log log
      • dataSource

        private javax.sql.DataSource dataSource
      • connection

        private java.sql.Connection connection
      • closeConnection

        private final boolean closeConnection
    • Constructor Detail

      • ManagedTransaction

        public ManagedTransaction​(java.sql.Connection connection,
                                  boolean closeConnection)
      • ManagedTransaction

        public ManagedTransaction​(javax.sql.DataSource ds,
                                  TransactionIsolationLevel level,
                                  boolean closeConnection)
    • Method Detail

      • getConnection

        public java.sql.Connection getConnection()
                                          throws java.sql.SQLException
        Description copied from interface: Transaction
        Retrieve inner database connection.
        Specified by:
        getConnection in interface Transaction
        Returns:
        DataBase connection
        Throws:
        java.sql.SQLException - the SQL exception
      • commit

        public void commit()
                    throws java.sql.SQLException
        Description copied from interface: Transaction
        Commit inner database connection.
        Specified by:
        commit in interface Transaction
        Throws:
        java.sql.SQLException - the SQL exception
      • rollback

        public void rollback()
                      throws java.sql.SQLException
        Description copied from interface: Transaction
        Rollback inner database connection.
        Specified by:
        rollback in interface Transaction
        Throws:
        java.sql.SQLException - the SQL exception
      • close

        public void close()
                   throws java.sql.SQLException
        Description copied from interface: Transaction
        Close inner database connection.
        Specified by:
        close in interface Transaction
        Throws:
        java.sql.SQLException - the SQL exception
      • openConnection

        protected void openConnection()
                               throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getTimeout

        public java.lang.Integer getTimeout()
                                     throws java.sql.SQLException
        Description copied from interface: Transaction
        Get transaction timeout if set.
        Specified by:
        getTimeout in interface Transaction
        Returns:
        the timeout
        Throws:
        java.sql.SQLException - the SQL exception