事务配置-基于tx/aop配置切面增强事务
来源:互联网 发布:视听语言 知乎 编辑:程序博客网 时间:2024/05/17 20:27
什么是事务?
所谓事务是用户定义的一个数据库操作序列,这些操作要么全做,要么全不做,是一个不可分割的工作单位
事务的特性?
原子性:要么全做,要么全不做。
一致性:说的是全部做,和全不做,这时数据库处于一致性,如果一个做,一个不做,就认为不一致。
隔离性:一个事务的执行不能被其他事务干扰,即一个事务的内部操作以及使用的数据对其他并发事务是隔离的。
持续性:一个事务一旦提交,它对数据库中数据的改变就应该是永久行的。
如何声明事务管理
基于TransactionProxyFactoryBean方式
基于tx/aop配置切面增强事务
基于注解
本篇主要说下,基于tx/aop配置切面增强事务。
1:引入命名空间
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
2:tx\aop核心配置
<!-- 配置事务属性 --><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes> <tx:method name="add*" propagation="REQUIRES_NEW" /> <tx:method name="update*" propagation="REQUIRES_NEW" /> <tx:method name="delete*" propagation="REQUIRES_NEW" /> <tx:method name="*" read-only="true"/></tx:attributes></tx:advice><!-- 配置事务切入点,以及把事务切入点和事务属性关联起来 --><aop:config proxy-target-class="true"><aop:pointcut expression="execution(* com.yc.service.*.*(..))" id="ServicePointcut" /><aop:advisor advice-ref="txAdvice" pointcut-ref="ServicePointcut" /></aop:config>
在标签中,常见属性及其说明如下,其中,除了name属性是必选外,其他都是可选的:
阅读全文
0 0
- 事务配置-基于tx/aop配置切面增强事务
- spring学习笔记(23)基于tx/aop配置切面增强事务
- Spring基于tx/aop声明式事务配置
- Spring基于tx/aop声明式事务配置
- Spring配置切面事务
- Spring配置事务切面
- Spring 事务切面配置
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- spring tx:advice 和 aop:config 配置事务
- guacamole谷歌浏览器全屏时白屏问题
- jQuery选择器,操作元素,工具方法,事件操作
- selenium报错Element is not clickable at point及四种解决方法
- vim编辑文章后不能修改
- caffe使用日志文件绘制Loss Accuracy图像
- 事务配置-基于tx/aop配置切面增强事务
- linux下编程输入密码不回显
- Java虚拟机学习之Java内存模型
- react-native之Androidstudio安装问题总结
- 验证正则表达式(一),同时验证手机号码和固定电话号码
- 不相交集ADT
- Error while performing database login with the Mysql connector driver;Unknown database 'test'
- [bzoj3590]SNOI2013 Quare
- AR是什么?能带来哪些黑科技?