API usage: Transaction.close

4 views
Skip to first unread message

Justin

unread,
Jul 29, 2010, 11:08:54 AM7/29/10
to hawtdb
I am sorry if I have many questions, hopefully I can put the answers
back into the javadoc.

When would I want to use Transaction.close() over Transaction.commit()
or Transaction.rollback()? Must I always call Transaction.close()?
For example, is the 'correct' canonical transaction something like:

Transaction tx = paged.tx();
try { // do work within the transaciton
tx.get(...); tx.put(...);
..
tx.commit();
} catch (Exception ex) {
tx.rollback();
} finally {
tx.close();
}

From the implementation it seems like some kind of safety check if you
intend on reusing a single transaction object multiple times, but I
don't really see why I would ever need/want to call it.

Hiram Chirino

unread,
Jul 29, 2010, 11:35:57 AM7/29/10
to haw...@googlegroups.com
Yes it's mostly for a saftey check. The close() method is only there
to get some assertion support. Once, closed, the transaction will
throw errors if you try to use it.

--
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://fusesource.com/

Reply all
Reply to author
Forward
0 new messages