-
1. Re: What order of operation when I use UserTransaction
mmusgrov Jun 15, 2010 6:09 AM (in response to michal_szymanski)If you are running inside an application server and obtaining the connection via the JBoss connection manager (which will be the case if you are using a JNDI lookup to obtain a datasource from which you obtain your connection, or are using injection) then the order does not matter.
On the other hand if you are running as a remote client then you will need extra support to enlist JDBC resources (in this case UserTransaction just delagates transaction calls to the server and does not do anything with resources).
So, I am answering this question from the point of view of the JEE specification and are assuming that you are using bean managed transactions (and are using JNDI or injection to obtain resources and transactions). When you obtain a connection, wrapper code checks to see if there is a transaction running and, if so, enlists it with the transaction. Alternatively, if you open a connection first and then start a transaction then the connection will be wrapped and when you invoke methods on the connection the wrapper will ensure that the resource is enlisted.
Similarly, when you release the connection or terminate the transaction then the resource associated with the connection is delisted.