jfinal事物回滚,@Before(Tx.class)和Db.tx(new IAtom() { })
来源:互联网 发布:广联达软件官网 编辑:程序博客网 时间:2024/04/30 05:44
一、注解 @Before(Tx.class) 加事物回滚
@Before(Tx.class)public void pay() throws Exception {//throws exception;}
方法体不能扑捉异常,所有的异常都抛出,当出现异常时事物将回滚
优点:简单暴力,不需要去处理每个异常,直接抛出即可;
缺点:不能详细的区分返回数据、视图,只能笼统的报出异常
二、Db.tx(new IAtom() { })
public void pay() {final Map<String,String> map = new HashMap<String, String>();boolean bl = Db.tx(new IAtom() {@Overridepublic boolean run() throws SQLException {if (...) {//...return false;} else {...return true;}return true;}});this.rendJson(bl, null,map.get("return_words"),null);}
return false 或者有异常抛出都会回滚事务,return true 才会提交事务,Db.tx 方法是有返回值true/false,可对改返回值作业务返回,如果想让 run 方法中往外层传递变量,可以在外层定义一个 final 修饰的容器类的对象或者定义map,二较一更全面,处理更细腻,推荐使用二。
0 0
- jfinal事物回滚,@Before(Tx.class)和Db.tx(new IAtom() { })
- jfinal TX 捕获异常
- Jfinal 事物应用回滚
- tx
- TX
- TX
- TX
- TX
- jFinal 事物控制回滚(简单)
- jfinal事物回滚实现方式
- tx标签配置事务却无法回滚
- spring 事物通过<tx 标签配置
- spring tx:advice ...aop:config配置事物
- Spring定义事物通知tx:advice
- 游戏开发入门系列(TX Class)
- Jfinal事务回滚
- palm tx
- tx.begin
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor
- WordPress在SAE环境上传文件至storage存储
- 网站被挂木马与777权限的奥妙
- innodb存储引擎中不同sql在不同隔离级别下锁的比较
- 宏观角度看数字编码
- jfinal事物回滚,@Before(Tx.class)和Db.tx(new IAtom() { })
- 廖雪峰Python教程 学习笔记4 Python基础
- Qt调用quazip来解压和压缩文件
- VS 2015 编译一些库的时候,出现 error “fatal error C1189: #error: Macro definition of snprintf conflicts with St
- 使用SQL语言创建数据库和表
- Android 反编译APK + 工具(亲测可用)
- 懒汉式单利模式多线程终极解决方案
- 04-树7 二叉搜索树的操作集 (30分)
- 第一次学习Linux