You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Alistair Young <al...@gmail.com> on 2008/04/08 12:51:41 UTC
iBATIS with JTA
Hello all,
I've been using iBATIS for a while quite successfully with a
transactionManager type of "JDBC" - however, I now want to use JTA and
am not having so much luck.
I have a block of code like this:
// start a transaction
dao.startTransaction();
// get and update a database entry
ColourDto colour = dao.findColour(1L);
colour.setColour("PINK");
dao.update(colour);
// rollback
dao.endTransaction();
The methods on my 'dao' object are pretty trivial calls onto the
methods of an instance of SqlMapClient.
With a JDBC SqlMap, I get the behaviour I expect: the database is
unchanged. However, with a JTA SqlMap, the rollback is ignored (and
so the database is updated).
The relevant bit of my SqlMap configuration is like this:
<transactionManager type="JTA">
<property name="UserTransaction"
value="java:comp/UserTransaction"/>
<dataSource type="JNDI">
<property name="DataSource" value="java:my/ds"/>
</dataSource>
</transactionManager>
I'm executing my code within Oracle's OC4J container. For my
DataSource I've tried both a very simple (bespoke) implementation of
the DataSource interface, and also an instance of the
OracleXADataSource class. It's probably also worth mentioning that
I'm not using EJBs.
Can anybody help? I think I must be missing something pretty
fundamental - so apologies if this is a stupid question...
Much appreciated!
Alistair.
Re: iBATIS with JTA
Posted by Alistair Young <al...@gmail.com>.
On 08/04/2008, Alistair Young <al...@gmail.com> wrote:
> Hello all,
>
> I've been using iBATIS for a while quite successfully with a
> transactionManager type of "JDBC" - however, I now want to use JTA and
> am not having so much luck.
>
> [ ... snip ...]
>
> Can anybody help? I think I must be missing something pretty
> fundamental - so apologies if this is a stupid question...
>
> [ ... snip ...]
>
Well, it turns out it was a pretty stupid question. I'd created my
DataSource locally and bound it to the JNDI manually... by specifying
the DataSource as a managed resource I seem to be having somewhat more
success...!
Cheers,
Alistair.