ibatis-user-java mailing list archives

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

On 12-Nov-07, at 4:21 PM, Christopher Lamey wrote:

> No, startT makes no claim (and most likely can't make such a claim)  
> to clean
> up properly if it encounters an exception.

I think that answers my question, so I may assume that "...it is safe  
and in fact necessary to call endTransaction() if startTransaction()  
throws an exception."

thanks
--Toby

>
> On 11/12/07 10:57 AM, "Toby Thain" <toby@smartgames.ca> wrote:
>
>>
>> On 12-Nov-07, at 3:56 PM, Toby Thain wrote:
>>
>>>
>>> On 12-Nov-07, at 3:27 PM, Gwyn Evans wrote:
>>>
>>>> No idea if it's possible, but the first case allows for the
>>>> transaction being created then an exception being thrown in the
>>>> 'start' operation, whereas with the second case, that would  
>>>> leave the
>>>> transaction open.
>>>
>>> Wouldn't that be a bug?
>>
>> ...in startTransaction(), I mean...
>>
>> --Toby
>>
>>>
>>> --Toby
>>>
>>>>
>>>> /Gwyn
>>>>
>>>> On 12/11/2007, Toby Thain <toby@smartgames.ca> wrote:
>>>>> 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
>>>>>
>>>>
>>>>
>>>> -- 
>>>> Download Wicket 1.3.0-rc1 now! - http://wicketframework.org
>>>
>>
>


Mime
View raw message