db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Leggett <minf...@sharp.fm>
Subject Re: Torque and JTA
Date Mon, 13 Oct 2008 16:44:29 GMT
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


Mime
View raw message