understanding JTA Spring and Bitronix
Asked Answered
S

2

6

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

What should I use for transactions in Hibernate persistence?

Stanhope answered 1/3, 2011 at 11:0 Comment(0)
P
20
  • 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.
Preengage answered 1/3, 2011 at 11:30 Comment(5)
what is the difference between distributed transactions and not? as well what do you mean by on a full blown application?Stanhope
@Odelya: Distributed transactions spread over several transactional resources (such as databases and message queues). If you have only one database, you don't need them. By full-blown application servers I mean products as JBoss, WebSphere and WebLogic, in contrast with servlet containers such as Tomcat and Jetty.Preengage
can I use HibernateTransactionManager and JtaTransactionManager in the same application context?Stanhope
@Odelya: If you actually need, you can: static.springsource.org/spring/docs/3.0.x/…. Note that it doesn't mean that they can participate in the same transaction.Preengage
I am using 2 mechanisms: accessing Hibernate with hibernate config, and accessing it with persistence. (it's becuase I am working with JBPM5 - jboss workflow where persistence file is required and in my application I don't like this way so I am using hibernate config.) so in jbpm5 - the persistence I need to work with JTA and they recommend BTM. in my application (which is the integrated with jbpm5) I don't need JTA and work with spring transactionsStanhope
L
2
  • 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.

Laoighis answered 12/12, 2016 at 12:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.