Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

understanding JTA Spring and Bitronix

I am trying to understand what is the difference between JTA, Spring and Bitronix?

What should I use for transactions in Hibernate persistence?

like image 936
Dejell Avatar asked Mar 01 '11 11:03

Dejell


People also ask

What is JTA spring?

JTA Transactional annotation applies to CDI-managed beans and classes defined as managed beans by the Java EE specification, whereas Spring's Transactional annotation applies only to Spring beans. It's also worth noting that support for JTA 1.2 was introduced in Spring Framework 4.0.

How does JTA transaction work?

The Java™ Transaction API (JTA) allows applications to perform distributed transactions, that is, transactions that access and update data on two or more networked computer resources.

What is Bitronix transaction manager?

Bitronix Transaction Manager allows Mule to automatically recover interrupted transactions on restart.

What is JPA and JTA in Java?

JPA (Java Persistence API) is the Java ORM standard/specification for storing, accessing, and managing Java objects in a relational database. Hibernate is an implementation of the Java Persistence API (JPA) specification. JTA (Java Transaction API) is the Java standard/specification for distributed transactions.


1 Answers

  • 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.
like image 80
axtavt Avatar answered Sep 24 '22 05:09

axtavt