| java.lang.Object org.apache.torque.util.Transaction
Transaction | final public class Transaction (Code) | | Refactored begin/commit/rollback transaction methods away from
the BasePeer .
This can be used to handle cases where transaction support is optional.
The second parameter of beginOptionalTransaction will determine with a
transaction is used or not.
If a transaction is not used, the commit and rollback methods
do not have any effect. Instead it simply makes the logic easier to follow
by cutting down on the if statements based solely on whether a transaction
is needed or not.
author: Stephen Haberman version: $Id: Transaction.java 476550 2006-11-18 16:08:37Z tfischer $ |
begin | public static Connection begin() throws TorqueException(Code) | | Begin a transaction for the default database.
This method will fallback gracefully to
return a normal connection, if the database being accessed does
not support transactions.
The Connection for the transaction. throws: TorqueException - Any exceptions caught during processing will berethrown wrapped into a TorqueException. |
begin | public static Connection begin(String dbName) throws TorqueException(Code) | | Begin a transaction. This method will fallback gracefully to
return a normal connection, if the database being accessed does
not support transactions.
Parameters: dbName - Name of database. The Connection for the transaction. throws: TorqueException - Any exceptions caught during processing will berethrown wrapped into a TorqueException. |
beginOptional | public static Connection beginOptional(String dbName, boolean useTransaction) throws TorqueException(Code) | | Begin a transaction. This method will fallback gracefully to
return a normal connection, if the database being accessed does
not support transactions.
Parameters: dbName - Name of database. Parameters: useTransaction - If false, a transaction won't be used. The Connection for the transaction. throws: TorqueException - Any exceptions caught during processing will berethrown wrapped into a TorqueException. |
commit | public static void commit(Connection con) throws TorqueException(Code) | | Commit a transaction. This method takes care of releasing the
connection after the commit. In databases that do not support
transactions, it only returns the connection.
Parameters: con - The Connection for the transaction. throws: TorqueException - Any exceptions caught during processing will berethrown wrapped into a TorqueException. |
rollback | public static void rollback(Connection con) throws TorqueException(Code) | | Roll back a transaction in databases that support transactions.
It also releases the connection. In databases that do not support
transactions, this method will log the attempt and release the
connection.
Parameters: con - The Connection for the transaction. throws: TorqueException - Any exceptions caught during processing will berethrown wrapped into a TorqueException. |
safeRollback | public static void safeRollback(Connection con)(Code) | | 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.
Parameters: con - The Connection for the transaction. See Also: Transaction.rollback(Connection) |
|
|