ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Toby Thain <t...@smartgames.ca>
Subject proper use of start/endTransaction()
Date Mon, 12 Nov 2007 16:52:07 GMT
Hi,

A little thought has been bothering me for a while and I thought I  
would put it to the experts.

The iBATIS manual advises the following logic for transactions:

try {
	sqlMap.startTransaction ();
	// ...queries
	sqlMap.commitTransaction ();
} finally {
	sqlMap.endTransaction ();
}

I am curious if it would be more strictly correct to:

sqlMap.startTransaction ();
try {
	// ...queries
	sqlMap.commitTransaction ();
} finally {
	sqlMap.endTransaction ();
}

In the event that startTransaction() itself throws an Exception...

Thoughts?
--Toby

Mime
View raw message