On Mar 13, 2007, at 8:37 PM, Daniel Kalcevich wrote:
Is there a reason you were calling the start, end and commit
transaction within Spring?
Do you mean why I'm I doing it in my Java code instead of doing it
declaratively?
The only reason is that I haven't learned how to do that yet.
If you know a good web page that shows how to do that, I'd love to
get the URL.
We use DAO's with Spring as our TransactionManager. Not sure if
you are using the SqlMapClientBean from Spring or not. But I
noticed the transactions being declared, but also the fact we use
the method getSqlMapClientTemplate(). Just some thoughts.
All things I don't know how to do yet, but I'm definitely open to
looking at alternatives, especially since what I'm doing isn't
working. Thanks for the tips! Any code examples would be greatly
appreciated!
Daniel
________________________________
From: Mark Volkmann [mailto:[EMAIL PROTECTED]
Sent: Tue 3/13/2007 6:34 PM
To: user-java@ibatis.apache.org
Subject: Re: transactions with Spring DAOs
On Mar 13, 2007, at 5:30 PM, Larry Meadors wrote:
Version 5 will work for you, you just have to define the tables using
the innodb engine.
http://dev.mysql.com/doc/refman/5.0/en/using-innodb-tables.html
Thanks for the tips! I followed the directions, adding
"ENGINE=InnoDB" to the end of all my table create commands, dropped
the tables, and recreated them. My code still runs as if autocommit
is enabled. I assumed that would be disabled just by explicitly
demarcating the beginning of a transaction, but that alone isn't
doing it.
Is there a way I can verify that my tables are setup for InnoDB?
Is there something else I need to do to disable autocommit for MySQL?
Should I ditch MySQL and use Postgres? ;-)
Larry
On 3/13/07, Mark Volkmann <[EMAIL PROTECTED]> wrote:
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 <[EMAIL PROTECTED]> 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();
}
<winmail.dat>