Cool, but pretty confusing if one wants it to return data. The docs
are
inconsistent regarding the necessity of the generic parm "ResultType".
Can you point out where they are inconsistent? I think you are
confusing the DataType and the ResultType.
http://rifers.org/docs/api/com/uwyn/rife/database/
DbTransactionUser.html (read the class description)
If I understand the docs and the source code correctly, ...
1) I can use it with GQM's (if the GQM's are within compilation scope)
like so:
final DbQueryManager manager = new DbQueryManager(MyDatasource);
DbTransactionUser MyTxn = new DbTransactionUser(List<Object> Objs)
{
public void useTransaction() throws InnerClassException
{
Objs.add (GQM_1.doSomething());
Objs.add (GQM_2.doSomething());
GQM_1.doSomethingElse();
}
};
try { manager.inTransaction(MyTxn);
// success!
List<Object> ResultsOfSuccessfulTxn = MyTxn.getData();
}
catch (Exception e) {
// failed; rolled back
}
SomeObj result = new DbQueryManager(datasource).inTransaction(new
DbTransactionUser() {
public SomeObj useTransaction()
throws InnerClassException
{
// GQM logic or anything else
return someInstance;
}
});
If you read this:
http://rifers.org/docs/api/com/uwyn/rife/database/
DbTransactionUser.html#useTransaction()
You'll see that InnerClassException should be catched if you want to
handle an exception inside the transaction user.
2) An implicit commit() is performed at the _end_ of the
code block if and only if, _within_ the code block,
a) no exception is thrown, and
b) rollback() is not explicitly called.
Yes, that's totally intuitive, isn't it? Ie with useTransaction you
ensure that all the enclosed DB statements are executed within the
same transaction.
3) Therefore, _all_ DB actions that are to be grouped into a single
transaction must be grouped within this same single code block.
Not true, you can call any other method and do anything you like.
They will all be wrapped in the transaction, it propagates through
all the methods and classes that are called from thereon.
--
Geert Bevin Uwyn bvba
"Use what you need" Avenue de Scailmont 34
http://www.uwyn.com 7170 Manage, Belgium
gbevin[remove] at uwyn dot com Tel +32 64 84 80 03
PGP Fingerprint : 4E21 6399 CD9E A384 6619 719A C8F4 D40D 309F D6A9
Public PGP key : available at servers pgp.mit.edu, wwwkeys.pgp.net
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users