|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.torque.util.Transaction
public final class Transaction
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.
Method Summary | |
---|---|
static java.sql.Connection |
begin()
Begin a transaction for the default database. |
static java.sql.Connection |
begin(java.lang.String dbName)
Begin a transaction. |
static java.sql.Connection |
beginOptional(java.lang.String dbName,
boolean useTransaction)
Begin a transaction. |
static void |
commit(java.sql.Connection con)
Commit a transaction. |
static void |
rollback(java.sql.Connection con)
Roll back a transaction in databases that support transactions. |
static void |
safeRollback(java.sql.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 |
Method Detail |
---|
public static java.sql.Connection begin() throws TorqueException
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static java.sql.Connection begin(java.lang.String dbName) throws TorqueException
dbName
- Name of database.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static java.sql.Connection beginOptional(java.lang.String dbName, boolean useTransaction) throws TorqueException
dbName
- Name of database.useTransaction
- If false, a transaction won't be used.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static void commit(java.sql.Connection con) throws TorqueException
con
- The Connection for the transaction.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static void rollback(java.sql.Connection con) throws TorqueException
con
- The Connection for the transaction.
TorqueException
- Any exceptions caught during processing will be
rethrown wrapped into a TorqueException.public static void safeRollback(java.sql.Connection con)
con
- The Connection for the transaction.rollback(Connection)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |