spring boot 事务的一些实践
来源:互联网 发布:西门子博图软件 编辑:程序博客网 时间:2024/06/08 09:14
起先:
@Service@Transactional
class xxxService
indMsgDao.batchRead(userId); List<IndMsg> list = indMsgDao.findByUserId(userId, pageable); Integer total = indMsgDao.countByUserId(userId); int a = 1 / 0;
@Query("update IndMsg e set e.is_read = '1' where e.user_id = :user_id ") @Modifying Integer batchRead(@Param("user_id") Integer user_id);
这段代码抛出异常,但没有执行回滚
比较奇怪的是:
indMsgDao.batchRead(userId); int a = 1 / 0; List<IndMsg> list = indMsgDao.findByUserId(userId, pageable); Integer total = indMsgDao.countByUserId(userId);
参考了这个帖子:http://www.cnblogs.com/youzhibing/p/6127250.html
不同的是,我这边jdbctemplate是可以回滚的
顺便提一下,spring boot 事务配置
添加@EnableTransactionManagement注解,该注解启用了注解式事务管理 <tx:annotation-driven />,这样在方法上的@Transactional注解就起作用了,但是实际测试中不加这句,@Transactional注解依然有用
http://www.cnblogs.com/java-zhao/p/5350106.html
我试了下,即使没有@EnableTransactionManagement也能用
0 0
- spring boot 事务的一些实践
- Spring Boot 事务的使用
- Spring Boot 事务的使用
- Spring Boot 事务的使用
- Spring Boot 事务的使用
- Spring Boot 事务的使用
- Spring Boot 事务的使用
- Spring Boot 事务的使用
- Spring Boot 事务的使用
- spring事务的一些概念
- spring boot 事务讲解
- 关于spring boot 事务
- Spring Boot事务配置
- spring boot 事务
- spring-boot事务相关
- Spring Boot事务配置
- Spring boot的第一次简单上手实践
- Spring boot + elasticsearch的最简单实践
- 关于电流检测中分流电阻(Rshunt)选型应考虑的问题
- 地道美语听力播客 4
- DPCM
- zTree插件setting配置详解
- cocos2dx输出Log的几种方法
- spring boot 事务的一些实践
- 单链表的逆置
- windows下安装xgboost for python 的简单方法
- 微服务:分解应用以实现可部署性和可扩展性
- scrapy User Agent切换的两种方法
- jack server
- 动态规划:0-1背包问题
- Android入门(简介)
- js 对象