| java.lang.Object jpersist.TransactionManager
TransactionManager | abstract public class TransactionManager (Code) | | Encloses multiple database calls in a single transaction. This class must
be used with jpersist.PersistentObject.save(Transaction) calls to be
effective and/or using the TransactionManager.getDatabase() to work
with the database handler that is involved in the transaction.
An example of this is:
new TransactionManager(dbm) {
public void run() throws JPersistException
{
// Inserting individually
new Contact("alincoln", ...).save(this);
// and/or
getDatabase().saveObject(new Order("alincoln", ...));
// and/or
saveObject(new Order("alincoln", ...));
}
}.executeTransaction();
While the transaction manager handles beginning the transaction, ending the
transaction, committing the transaction, and rolling back the transaction,
it's still also possible to use save points, rollback, and commit at any
point within.
|
Method Summary | |
public void | commit() Calls the jpersist.Database version. | public int | deleteObject(Object object) Calls the jpersist.Database version. | public int | deleteObject(Object object, Set<String> nullValuesToInclude) Calls the jpersist.Database version. | public int | deleteObject(Object object, String externalClauses, Object... externalClausesParameters) Calls the jpersist.Database version. | public int | deleteObject(Object object, Set<String> nullValuesToInclude, String externalClauses, Object... externalClausesParameters) Calls the jpersist.Database version. | public void | executeTransaction() Call this method to execute the transaction (and the run() method). | public Database | getDatabase() Returns the database being used for the transaction. | public void | rollback() Calls the jpersist.Database version. | public void | rollback(Savepoint savepoint) Calls the jpersist.Database version. | abstract public void | run() Override this method with your own. | public int | saveObject(Object object) Calls the jpersist.Database version. | public int | saveObject(Object object, Set<String> nullValuesToInclude) Calls the jpersist.Database version. | public int | saveObject(Object object, String externalClauses, Object... externalClausesParameters) Calls the jpersist.Database version. | public int | saveObject(Object object, Set<String> nullValuesToInclude, String externalClauses, Object... externalClausesParameters) Calls the jpersist.Database version. | public Savepoint | setSavepoint() Calls the jpersist.Database version. | public Savepoint | setSavepoint(String name) Calls the jpersist.Database version. | public boolean | supportsSavepoints() Calls the jpersist.MetaData version. |
closeDatabase | boolean closeDatabase(Code) | | |
TransactionManager | public TransactionManager(DatabaseManager databaseManager) throws JPersistException(Code) | | This constructor takes a database manager.
Parameters: databaseManager - a jpersist.DatabaseManager instance |
TransactionManager | public TransactionManager(Database database) throws JPersistException(Code) | | This constructor takes a database.
Parameters: database - a jpersist.Database instance |
executeTransaction | public void executeTransaction() throws JPersistException(Code) | | Call this method to execute the transaction (and the run() method). If no
exceptions occur the transaction will be commited. Othwerwise, the
transaction will be rolled back.
|
getDatabase | public Database getDatabase()(Code) | | Returns the database being used for the transaction. This is useable for
any database functionality, including commits, Savepoints, and rollbacks.
|
run | abstract public void run() throws Exception(Code) | | Override this method with your own.
|
supportsSavepoints | public boolean supportsSavepoints() throws JPersistException(Code) | | Calls the jpersist.MetaData version.
|
|
|