Spring Transaction Management

PlatformTransactionManager(Interface)

Platform Spring PlatformTransactionManager
JDBC org.springframework.jdbc.datasource.DataSourceTransactionManager
JTA org.springframework.transaction.jta.JtaTransactionManager
Hibernate org.springframework.orm.hibernate5.HibernateTransactionManager

Declarative transaction management

@Transactional

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="
 http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx.xsd">
 
 <!-- enable transactional behavior based on annotation -->
 <tx:annotation-driven transaction-manager="txManager"/>
 
</beans>

Reference

廣告