|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.arch4j.dataaccess.DatabaseManager | +--org.arch4j.dataaccess.TransactionalDatabaseManager
This extention of the DatabaseManager class adds joinable transaction functionality. Transactions are necessary anytime multiple operations against the database need to be atomic. All inserts, updates and deletes for a given transaction will succeed or fail together. Typical use is something like the following:
DatabaseManager transDBMgr = TransactionalDataAccessProvider.getProvider();
transDBMgr.executeTransaction(
new AtomicOperationCommand() {
public void execute() throws DataAccessException {
// do multiple database operations using transDBMgr
...
}
}
);
Field Summary | |
protected static LoggingCategory |
loggingCategory
The logging category. |
Fields inherited from class org.arch4j.dataaccess.DatabaseManager |
connectionManager |
Method Summary | |
protected Connection |
beginDatabaseAction()
Override the base implementation of this method to add transactional behaviour. |
protected void |
endDatabaseAction(ResultSet jdbcResultSet,
Statement statement,
Connection aConnection)
Override the base implementation of this method to add transactional behaviour. |
BatchResult |
executeBatch(BatchQuery batchQuery)
Extends the base class, DatabaseManager, by adding rollback functionality on failure. |
void |
executeTransaction(AtomicOperationCommand aCommand)
Use this method to bound multiple database operations which need to execute as one atomic operation. |
boolean |
isMarkedForRollback()
Knows if the current or just executed transaction is marked for rollback. |
void |
markForRollback()
If this method is called at any time the transaction will rollback when endTransaction() is called. |
Methods inherited from class org.arch4j.dataaccess.DatabaseManager |
buildStatement, delete, execUpdate, execUpdate, execute, execute, execute, execute, execute, insert, notifyListener, select, select, update |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static LoggingCategory loggingCategory
Method Detail |
public void executeTransaction(AtomicOperationCommand aCommand) throws DataAccessException
DataAccessException
public void markForRollback()
public boolean isMarkedForRollback()
public BatchResult executeBatch(BatchQuery batchQuery) throws DataAccessException
executeBatch
in class DatabaseManager
DataAccessException
- If a database error occurs.protected Connection beginDatabaseAction() throws SQLException
beginDatabaseAction
in class DatabaseManager
SQLException
- If unable to connect or no more connections
available.protected void endDatabaseAction(ResultSet jdbcResultSet, Statement statement, Connection aConnection)
endDatabaseAction
in class DatabaseManager
jdbcResultSet
- The data produced by a query.statement
- The pre-compiled SQL statement.
|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |