编程式事务
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
• •propagation
一些配置 •isolation
•proxyTargetClass 定义基于接口还是类 true orfalse •timeout
•mode aop model是否使用aspectJ默认使用java就好 •readOnly
•order 事务拦截顺序默认最低 •怎么判断回滚 设置遇到特定异常类时回滚