Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.torque.util
Class TransactionManagerImpl

    java.lang.Object
      org.apache.torque.util.TransactionManagerImpl

All Implemented Interfaces:
  TransactionManager

    public class TransactionManagerImpl

extends Object
implements TransactionManager

Standard connection and transaction management for Torque. Uses JDBC connection operations and Torque's own database pools for managing connections and transactions.

Version:
  $Id: TransactionManagerImpl.java 1448414 2013-02-20 21:06:35Z tfischer $
Author:
  Stephen Haberman

Constructor Summary
`TransactionManagerImpl()`

Method Summary
`Connection` | `begin()` Begin a transaction by retrieving a connection from the default database connection pool.
`Connection` | `begin(String dbName)` Begin a transaction by retrieving a connection from the named database connection pool.
`void` | `commit(Connection con)` Commit a transaction and close the connection.
`void` | `rollback(Connection con)` Roll back a transaction and release the connection.
`void` | `safeRollback(Connection con)` Roll back a transaction without throwing errors if they occur.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TransactionManagerImpl

    public TransactionManagerImpl()

Method Detail

### begin

    public Connection begin()
                     throws TorqueException

  Begin a transaction by retrieving a connection from the default database connection pool. WARNING: If the database does not support transaction or the pool has set autocommit to true on the connection, the database will commit after every statement, regardless of when a commit or rollback is issued.

  Specified by:
    `begin` in interface `TransactionManager`
  Returns:
    The Connection for the transaction.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### begin

    public Connection begin(String dbName)
                     throws TorqueException

  Begin a transaction by retrieving a connection from the named database connection pool. WARNING: If the database does not support transaction or the pool has set autocommit to true on the connection, the database will commit after every statement, regardless of when a commit or rollback is issued.

  Specified by:
    `begin` in interface `TransactionManager`
  Parameters:
    `dbName` - Name of database.
  Returns:
    The Connection for the transaction.
  Throws:
    `TorqueException` - If the connection cannot be retrieved.

### commit

    public void commit(Connection con)
                throws TorqueException

  Commit a transaction and close the connection. If the connection is in autocommit mode or the database does not support transactions, only a connection close is performed

  Specified by:
    `commit` in interface `TransactionManager`
  Parameters:
    `con` - The Connection for the transaction.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### rollback

    public void rollback(Connection con)
                  throws TorqueException

  Roll back a transaction and release the connection. In databases that do not support transactions or if autocommit is true, no rollback will be performed, but the connection will be closed anyway.

  Specified by:
    `rollback` in interface `TransactionManager`
  Parameters:
    `con` - The Connection for the transaction.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### safeRollback

    public void safeRollback(Connection con)

  Roll back a transaction without throwing errors if they occur. A null Connection argument is logged at the debug level and other errors are logged at warn level.

  Specified by:
    `safeRollback` in interface `TransactionManager`
  Parameters:
    `con` - The Connection for the transaction.
  See Also:
    `rollback(Connection)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2013 The Apache Software Foundation. All Rights Reserved.