|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sormula.active.ActiveTransaction
public class ActiveTransaction
A class to group multiple active record operations within one JDBC transaction.
Only one instance of an ActiveTransaction may be in use for an instance of an ActiveDatabase at one time. Create one instance of an ActiveDatabase for each possible transaction that may occur at that same time.ActiveTransaction transaction = new ActiveTransaction(new ActiveDatabase(dataSource)); try { transaction.begin(); // ...some active operations... transaction.commit(); } catch (ActiveException e) { transaction.rollback(); }
Constructor Summary | |
---|---|
ActiveTransaction()
Constructs for the default active database. |
|
ActiveTransaction(ActiveDatabase activeDatabase)
Constructs an ActiveDatabase . |
Method Summary | |
---|---|
void |
begin()
Starts the transaction. |
protected void |
close()
Cleans up resources that are used by this transaction. |
void |
commit()
Completes the transaction. |
ActiveDatabase |
getActiveDatabase()
Gets the active database associated with this transaction. |
OperationTransaction |
getOperationTransaction()
Gets the operation transaction created by this transaction. |
void |
rollback()
Rolls back the transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ActiveTransaction() throws ActiveException
ActiveDatabase.setDefault(ActiveDatabase)
prior to using
this constructor.
Use this constructor only if no other thread may be using it at the same time. This is
the case since there is only one default ActiveDatabase
per classloader and only one
transaction may be in use per ActiveDatabase
.
ActiveException
- if errorpublic ActiveTransaction(ActiveDatabase activeDatabase) throws ActiveException
ActiveDatabase
.
activeDatabase
- active database associated with transaction
ActiveException
- if errorMethod Detail |
---|
public ActiveDatabase getActiveDatabase()
ActiveTransaction()
was used or the one supplied in
ActiveTransaction(ActiveDatabase)
.
public OperationTransaction getOperationTransaction()
public void begin() throws ActiveException
commit()
or rollback()
to close the transaction.
This method invokes ActiveDatabase.setActiveTransaction(ActiveTransaction)
to indicate
that this transaction is in use for the active database.
ActiveException
- if errorpublic void commit() throws ActiveException
Connection.commit()
on the underlying
JDBC connection. This method invokes ActiveDatabase.setActiveTransaction(ActiveTransaction)
with a null parameter to indicate that no transaction is in use for the active database.
ActiveException
- if errorpublic void rollback() throws ActiveException
Connection.rollback()
on the underlying
JDBC connection. This method invokes ActiveDatabase.setActiveTransaction(ActiveTransaction)
with a null parameter to indicate that no transaction is in use for the active database.
ActiveException
- if errorprotected void close() throws ActiveException
ActiveException
- if error
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |