You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Graham Leggett <mi...@sharp.fm> on 2008/10/13 18:44:29 UTC

Re: Torque and JTA

Thomas Fischer wrote:

>> From what I have managed to gather so far is that jta works by 
>> requesting callbacks with the JDBC driver, and this means you don't 
>> need to explicitly pass around any connection object representing the 
>> transaction, the transaction is associated with the thread in which 
>> you're running.
> 
> Does this mean that it is even an error to pass the connection around ???

No, it means it's an error to try and use the transactional calls on the 
connection. If you're using JTA, I understand that you should not call 
the transactional methods on JDBC.

In short, if you want to use JTA with Torque, you must use 
Torque.getConnection() to get a connection, then pass that connection to 
all torque methods while the transaction is in progress, then finally, 
call Torque.closeConnection(conn) when you are done.

Practically, you need to make sure that while your JTA transaction is 
active, torque doesn't try and perform any transactions on a second 
connection in the same thread. If you do you will get an explicit 
exception at the place where the second connection is used, so finding 
these bugs is pretty simple.

To sum up: yes you can use JTA and Torque together, just make sure you 
use one connection per thread.

Regards,
Graham
--

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org