I am trying to understand what is the difference between JTA, Spring and Bitronix?
开发者_如何学CWhat should I use for transactions in Hibernate persistence?
JTA is an API for distributed transaction management. It can be implemented as part of application server or as a standalone transaction manager.
Bitronix Transaction Manager is a standalone implementation of JTA.
Spring is a framework that provides (among other features) unified interface for transaction management. In particular, Spring-managed transaction can use JTA implementation as a backend.
In other words, in a typical Spring and Hibernate application you manage transactions using Spring transaction support, and Spring is configured to use one of backend transaction managers:
- If you don't need distributed transactions use Hibernate's own transaction support (
HibernateTransactionManager
) - If you need distributed transactions use JTA transactions (
JtaTransactionManager
). In particular:- On a full-blown application server
JtaTransactionManager
uses built-in JTA implementation - In standalone environment (such as Tomcat, etc) you need to configure standalone JTA implementation such as Bitronix.
- On a full-blown application server
- JTA is a java transaction api. By using JTA, we can perform global transaction.
- Bitronix is a software which helps to implement JTA. And also it helps to store data into database in a serialized way.
For example, when any transaction operation performed, at the same instant of time, amount should be deducted from one account and added in another account. But some time if second operation fails, then it does not rolled back the transaction. It also helps to avoid deadlock situation.
精彩评论