編程式事務
TransactionTemplate 其中設置當前操作傳播特性,隔離,超時propagtion isolation timeout
•TransactionCallback
•TransactionCallbackWithoutResult
PlatformTransactionManager
•可以傳⼊入TransactionDefinition進⾏行行定義
聲明式事務
利用aop的proxy,在目標方法上做了層封裝,幫助用戶進行模板式事務操作,在操作開始前啓動事務,在方法執行結束後commit或rollback這個事務。使用java默認的基於接口的動態代理,封裝了aspectJ,有切入點Advice,返回值的AfterReturning,在方法執行前有before,在方法後After,拋出異常時AfterThrowing,在這裏使用的是Around切入也就是在方法前後去做了一段的增強。
基於註解的配置⽅方式 instertruction?
開啓事務註解的⽅方式 @Transactional
•@EnableTransactionManagement •transactionManager dataSourceTransactionManager
•<tx:annotation-driven/> •propagation
一些配置 •isolation
•proxyTargetClass 定義基於接口還是類 true orfalse •timeout
•mode aop model是否使用aspectJ默認使用java就好 •readOnly
•order 事務攔截順序默認最低 •怎麼判斷回滾 設置遇到特定異常類時回滾