当前位置:网站首页>TransactionTemplate transaction programmatic way
TransactionTemplate transaction programmatic way
2022-07-31 06:01:00 【Floating life like a dream】
It is recommended to use declarative transaction @Transactional(rollbackFor = Exception.class) granularity is not enough, split method
import org.springframework.transaction.support.TransactionTemplate;@Autowiredprivate TransactionTemplate trans;/*** Programmatic transactions*/public void transfer() {// no return valuetrans.executeWithoutResult((status) ->{boolean save = this.save(t);if(!save) {status.setRollbackOnly();}});// have return valuetrans.execute((status) ->{boolean save = this.save(t);if(!save) {status.setRollbackOnly();}return new Object();});}
边栏推荐
- WeChat applet source code acquisition and decompilation method
- Gradle sync failed: Uninitialized object exists on backward branch 142
- 计网 Packet Tracer仿真 | 简单易懂集线器和交换机对比(理论+仿真)
- Chinese garbled solution in UTF-8 environment in Powershell
- Tencent Cloud Lightweight Server deletes all firewall rules
- SSH自动重连脚本
- VTK:Could not locate vtkTextRenderer object.
- mysql password modification method in Linux (pro-test available)
- quick-3.5 lua调用c++
- js中的函数
猜你喜欢
js中的this指向与原型对象
Principle analysis of famous website msdn.itellyou.cn
数据库 | SQL增删改查基础语法
Android软件安全与逆向分析阅读笔记
[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]
通信原理——纠错编码 | 汉明码(海明码)手算详解
安装Multisim出现 No software will be installed or removed解决方法
Sqlite column A data is copied to column B
VS2017 connects to MYSQL
MySQL高级语句(一)
随机推荐
[windows]--- SQL Server 2008 super detailed installation tutorial
MySQL分页查询的5种方法
This in js points to the prototype object
通信原理——纠错编码 | 汉明码(海明码)手算详解
cocos create EditBox 输入文字被刘海屏遮挡修改
cocos2d-x-3.2 Physics
js中的break与continue退出
quick-3.5 lua调用c++
场效应管 | N-mos内部结构详解
js中的全局作用域与函数作用域
On the side of Ali, tell me what are the application scenarios of message middleware you know?
Getting to know regular expressions
[uiautomation] Get WeChat friend list (stored in txt)
浅谈对分布式模式下CAP的理解
CMOS管原理,及其在推挽电路中的应用
mysql启动报错The server quit without updating PID file几种解决办法
unicloud 发布后小程序提示连接本地调试服务失败,请检查客户端是否和主机在同一局域网下
Take you to understand the MySQL isolation level, what happens when two transactions operate on the same row of data at the same time?
sql 添加 default 约束
腾讯云GPU桌面服务器驱动安装