We are using Spring with Hibernate to establish transactions with JTA. The PlatformTransactionManager is the JtaTransactionManager which is wired with the TransactionManager and UserTransaction from narayana.
@Bean
@Scope("prototype")
public TransactionManager jbossTransactionManager() {
return jtaPropertyManager.getJTAEnvironmentBean().getTransactionManager();
}
@Bean
@Scope("prototype")
public UserTransaction jbossUserTransaction() {
return jtaPropertyManager.getJTAEnvironmentBean().getUserTransaction();
}
@Bean
public PlatformTransactionManager transactionManager() {
return new JtaTransactionManager(jbossUserTransaction(), jbossTransactionManager());
}
I have noted that JtaTransactionManager has the UT and TM I would want. On JBoss 6 EAP, I noted that my DataSource has been used as a WrapperDataSource and that this was related to a different TM. Specifically, it is using the TransactionManagerDelegate. This appears to be the transaction manager provided by JBoss via the JNDI names java:TransactionManager
and java:jboss/TransactionManager
. This is preventing my transactions from having transactional boundaries and I leak data on flush. If I remove my configuration and the UT and TM from the container, my transactions transact properly.
- What is deciding to use this other TransactionManager? This appears to be the JCA from the container but I do not understand the mechanism for this decision.
- Should I remove my UT and TM and surrender control to the container to give these components to my app and rely on the JTA platform as is or should I try to gain more control?
This is preventing my transactions from having transactional boundaries and I leak data on flush.
please explain this with more details. It's difficult to understand what it means. – ben75ActionQueue#executeActions
in Hibernate and see that the data is not committed before theexecuteActions( insertions );
and that it is in the database afterwards. (Verified by a different program manually querying the database. I am starting to believe that JBoss's JCA is deciding to use this other TransactionManager rather than my Spring bean version. I do not yet fully grok this. – user2832162