ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Volkmann <m...@ociweb.com>
Subject Re: transactions with Spring DAOs
Date Tue, 13 Mar 2007 20:12:53 GMT
On Mar 13, 2007, at 3:04 PM, Larry Meadors wrote:

> Are you using MySQL w/o innodb, or some other database that is not
> transaction aware?

Ahh ... that may be the issue. I'm using MySQL version 5.0.27- 
standard. I assumed that all newer versions of MySQL were transaction  
aware. Is that wrong? Perhaps I need to download a different version.

> Larry
>
>
> On 3/13/07, Mark Volkmann <mark@ociweb.com> wrote:
>> I seem to be getting automatic transactions when I use Spring DAOs
>> generated by Abator even though my SqlMapConfig.xml contains the
>> following.
>>
>>    <transactionManager type="JDBC">
>>      <dataSource type="SIMPLE">
>> ...
>>
>> Here's the simple bit of code I'm using to test this. The change to
>> addressId is persisted even though a RunTime exception is thrown
>> inside the try and commitTransaction is not called. Any idea what I
>> might be doing wrong?
>>
>>      boolean problem = true;
>>      Person person = personDAO.selectByPrimaryKey(markId);
>>      SqlMapClient smc = ((SqlMapClientDaoSupport)
>> personDAO).getSqlMapClient();
>>      try {
>>        smc.startTransaction();
>>
>>        person.setAddressId(addressId);
>>        personDAO.updateByPrimaryKey(person);
>>        System.out.println("updated address"); // This is output.
>>
>>        // What happens if an exception occurs here?
>>        if (problem) throw new RuntimeException("something bad
>> happened");
>>
>>        person.setHomePhoneId(homePhoneId);
>>        personDAO.updateByPrimaryKey(person);
>>        System.out.println("updated home phone"); // This isn't  
>> output.
>>
>>        smc.commitTransaction();
>>      } finally {
>>        smc.endTransaction();
>>      }
>>


Mime
View raw message