Java Reference
In-Depth Information
Listing 6-28.
transaction-config.xml
<beans>
<bean id="jpaTransactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory"
ref="entityManagerFactory" />
</bean>
</beans>
Note that this transaction manager needs an entity manager factory, that is, an
implementation of the
javax
.
persistence
.
EntityManagerFactory
. This factory provides the
EntityManager
. The
JpaTransactionManager
uses this
EntityManager
to coordinate transac-
tions.
JTA Transactions
The transaction managers described earlier are not very suitable for distributed XA
transactions. XA describes a protocol to coordinate transactions involving multiple trans-
action and resource managers. BEA WebLogic Server and JBoss Application Server (AS)
are examples of transaction managers. They manage transactions involving multiple
resource managers such as databases, messaging providers such as IBM MQ Series,
mainframes, and so on.
In such scenarios you will need to use the
JTATransactionManager
. It generally dele-
gates the transaction handling responsibility to the underlying JTA implementation
provided by BEA WebLogic Server, JBoss AS, ObjectWeb JOTM, or Atomikos. Listing 6-29
shows the configuration of
JTATransactionManager
.
Listing 6-29.
transaction-config.xml
<beans>
<bean id="transactionManager" class="org.springframework.
å
transaction.jta.JtaTransactionManager">
<property name="transactionManagerName"
value="java:/TransactionManager" />
</bean>
</beans>
JtaTransactionManager
works with the
javax.transaction.UserTransaction
and
javax.transaction.TransactionManager
objects, delegating responsibility for transaction
management to those objects. A successful transaction will be committed with a call to
