Why are there different types of transaction managers?

I am confused about different types of transaction manager in a web application:

Spring Transaction Operator vs JPA Transaction Manager vs Hibernate Transaction Manager vs JTA Transaction Manager and Database Transaction Manager

I did some searches about the aforementioned transaction managers but it is still unclear.

For example:

Hibernate tx manager

uses Database tx manager

JPA tx manager

uses the Hibernate tx

 manager

Spring tx manager

uses JPA transaction manager

orJTA tx manager

Edited: An example config from my application is below: samaple

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
        <property name="jpaDialect">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
        </property>
    </bean> 

      

and

<prop key="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform</prop>
                <prop key="transaction.auto_close_session">true</prop>
                <prop key="current_session_context_class">jta</prop>

      

so if I go through the above example, the JPA transaction operator is using the hibernate transaction manager and in turn the sleeping manager is using the JTA manager, am I correct?

Does this mean that every transaction manager uses a base transaction manager?

+3


source to share


1 answer


When you say "every transaction manager uses and manages transactions", you are not entirely correct.

Taking Spring for example, the transaction strategy is defined by the interface PlatformTransactionManager

. It is not tied to a search strategy like JNDI. Implementations are PlatformTransactionManager

defined like any other object (or bean) in the Spring Framework IoC container. This advantage in itself makes Spring Framework transactions a worthwhile abstraction even when dealing with JTA. Transactional code can be tested much more easily than if it were using JTA directly.



So, Spring offers several implementation possibilities regarding database transaction management.

0


source







All Articles