NutzCN Logo
问答 回滚后 数据表插入错误日志
发布于 1847天前 作者 啊哈 1471 次浏览 复制 上一个帖子 下一个帖子
标签:
// 检查余量
			Trans.exec(new Atom() {
			    Record _r = null;
				@Override
				public void run() {
					int i = sendMsgDao.editMsgCount(r.getString("corp_id"));
					if (i < 1) {// 更新失败--余量不足
						sendMsgDao.editMsgRecordById(Chain.make("send_state", 0).add("error_msg", "短息余量不足"),
								Cnd.where("id", "=", r.getString("id")));
					} else {
						_r = SendMsgUtil.smsSend(r.getString("accept_phone"), r.getString("content"), "", r.getString("attime"));
					   if(_r.getString("code").equals("500")){//发送失败
						   //插入错误日志
						   sendMsgDao.editMsgRecordById(Chain.make("send_state", 0).add("error_msg",_r.get("msg")),
									Cnd.where("id", "=", r.getString("id")));
						   //回滚
						   throw new RuntimeException("回滚");
					   }
					}
				}
			});

怎么才能回滚后,往数据表插入的错误日志不回滚。

4 回复

错误日志在Trans之外插入,或者用NutTxDao来单独插入错误日志

new NutTxDao 和Trans.begin(),commit() 有什么区别啊,怎么有两种手动事务。

这两个该用哪个呢

文档有, NutTxDao是独立事务, 脱离Trans的

添加回复
请先登陆
回到顶部