Spring封裝JdbcTemplate和事務控制

xml 文件輸入

<?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:aop="http://www.springframework.org/schema/aop"
       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
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">
    

1.maven導入

a.jdbc包

在這裏插入圖片描述

b.tx事務包

在這裏插入圖片描述

2.當繼承了Spring中的JdbcDaoSupport後只能使用xml註解配置,因爲源碼無法修改

在這裏插入圖片描述

3.tx事務控制PlatformTransactionManager接口

在這裏插入圖片描述

3.1 PlatformTransactionManager常用實現類

  1. DataSourceTransactionManager使用SpringJdbc或者iBatis進行持久化數據時使用
  2. HibernateTransactionManager使用Hibernate版本進行持久化數據時使用

4.1 tx事務管理常用接口二——TransactionDefinition

在這裏插入圖片描述

4.1.1 事務的管理級別

在這裏插入圖片描述

4.1.2 事務的傳播行爲

在這裏插入圖片描述

4.1.3 超時時間

在這裏插入圖片描述

4.1.4 是否爲只讀事務

查詢建議設置爲只讀

5.1 tx事務管理常用接口二——TransactionStatus事務狀態

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章