spring添加事务管理
来源:互联网 发布:sas聚类分析共现矩阵 编辑:程序博客网 时间:2024/05/22 02:04
bean.xml的配置:
<tx:annotation-driven transaction-manager="transactionManager"/> <!--开启注解对事务的管理,发现使用spring事务管理器会出现bug--> <!-- 定义事务管理器(声明式的事务) --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sf"/> <!--<property name="dataSource" ref="dataSource"/>--> </bean>
添加schema:
<?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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd" default-autowire="byName">
然后在service层加上注解:
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED, isolation = Isolation.REPEATABLE_READ)
即可使用spring的事务管理.
0 0
- spring添加事务管理
- 添加事务管理
- 事务管理之Spring事务管理
- Spring事务管理
- spring事务管理
- Spring事务管理
- Spring事务管理
- Spring事务管理
- Spring事务管理
- Spring事务管理
- Spring 事务管理
- Spring事务管理
- spring 事务管理
- spring 事务管理
- spring 事务管理
- spring事务管理
- Spring 事务管理
- Spring事务管理
- 数学 求平行四边形的面积和坐标
- poj 3233Matrix Power Series(矩阵快速幂 二分求和 求累乘的和)
- 插入排序算法
- Android开发 Fiddler抓包
- MESPRO
- spring添加事务管理
- 关于处理Android 异常NetworkOnMainThreadException解决方案
- Android工具类--日志管理类
- 人人皆懂得KMP算法
- UVALive - 4256 || LA 4256 Salesmen 商人(DP)
- SVM边学边总结系列——非线性可分情况
- poj 3735Training little cats(矩阵快速幂 完成模拟 注意优化)
- java基础知识点
- 为什么32位机器最大只能用到4GB内存