According to Hibernate docs, in a JTA environment the default connection release mode is after_statement, meaning that after each statement the hibernate logical connection is released.
When the logical connection is released, the Connection close() method is called and the current resource is de-listed from the transaction manager.
According to RedHat transaction developer guide:
"The delistResource method is used to dissociate the specified resource from the transaction context in the target object. The application server invokes the method with two parameters:
An XAResources object, which represents the resource.
A flag to indicate whether the operation is due to the transaction being suspended (TMSUSPEND), a portion of the work has failed (TMFAIL), or a normal resource release by the application (TMSUCCESS)."
Since Bitronix uses TMSUCCESS:
currentTransaction.delistResource(xaResourceHolderState.getXAResource(), XAResource.TMSUCCESS);
It means the connection is disassociated from the current transaction branch and sometimes you may end up enlisting 2 different connections for the same Resource Adapter.
I think that holding the connection for as much as the Transaction is taking place is a better choice, since we usually execute more than one statement per transaction. So the after_transaction release mode sounds more appealing.
Is the after_transaction release mode more appropriate with Bitronix? Has anyone experienced it in a production environment?