ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alistair Young" <alistair.j.yo...@gmail.com>
Subject Another JTA question - nested transactions
Date Tue, 08 Apr 2008 14:02:45 GMT
Hello again,

After figuring out my previous problem, I've got my iBATIS/JTA test
application working up to a point (start transaction, update followed
by end or commit).

Now, according to the book "iBATIS in Action", when configured to use
a JTA transactionManager, "iBATIS will look for the global transaction
context and attempt to manage it appropriately.  This means that
iBATIS can check the state of an existing transaction or start one if
necessary."  It also states that "you should still start, commit and
end the 'inner transaction scope'".

Given this, I'd expected to be able to write code like this;

       // start a transaction
       // [iBATIS starts a new JTA transaction...?]

       // ... do some database processing ...

       // start an inner transaction
       // [iBATIS joins the existing JTA transaction...?]

       // ... do some more database processing ...

       // abandon the inner transaction
       // [iBATIS issues setRollbackOnly on JTA transaction...?]

       // commit the outer transaction
       // [iBATIS issues commit on JTA transaction...?]

with the final result that the database is unchanged.  However,
instead, I get an exception on my second call to startTransaction()
complaining that a transaction is already started.

Obviously what I'm ultimately looking to do is to coordinate a number
of distinct database interactions into a single transaction - but this
example demonstrates my problem, I think.

Can anybody suggest how I might achieve this?

Thanks again,


View raw message