|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.database.DbTransactionUser<ResultType,DataType>
public abstract class DbTransactionUser<ResultType,DataType>
By extending this class it's possible to provide the logic that should be
executed by the inTransaction
method in the DbQueryManager class.
This class has both a default constructor and one that can take a data
object. This can be handy when using it as an extending anonymous inner
class when you need to use variables inside the inner class that are
cumbersome to change to final in the enclosing class.
DbQueryManager.inTransaction(DbTransactionUser)| Field Summary | |
|---|---|
protected DataType |
mData
|
| Constructor Summary | |
|---|---|
DbTransactionUser()
|
|
DbTransactionUser(DataType data)
|
|
| Method Summary | |
|---|---|
Object |
clone()
Simply clones the instance with the default clone method since this class contains no member variables. |
DataType |
getData()
|
int |
getTransactionIsolation()
Should be overridden if the transaction has to be executed in another isolation level. |
void |
rollback()
Should be used to roll back ongoing transactions, otherwise enclosing transaction users might not be interrupted and subsequent modification can still happen outside the transaction. |
void |
throwException(Exception exception)
Calling this method makes it possible to throw a checked exception from within this class. |
abstract ResultType |
useTransaction()
Should be implemented by all extending classes. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DataType mData
| Constructor Detail |
|---|
public DbTransactionUser()
public DbTransactionUser(DataType data)
| Method Detail |
|---|
public DataType getData()
public int getTransactionIsolation()
-1 when the active isolation level should be
preserved; or
a level constant from Connection if the
isolation needs to be changed.
public void rollback()
throws RollbackException
RollbackException - indicates that a rollback should happen
and all further transaction logic interrupted.
public void throwException(Exception exception)
throws InnerClassException
To catch it you should surround the inTransaction with a
try-catch block that catching
InnerClassException. The original exception is then
available through getCause() and can for example be
rethrown.
InnerClassException - when a checked exception needs to be
thrown from within this class and caught outside the caller.
public abstract ResultType useTransaction()
throws InnerClassException
InnerClassExceptionpublic Object clone()
clone in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||