码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis 回滚记录

时间:2017-08-14 12:43:27      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:insert   方法   addgroup   int   use   order   ddp   tran   upd   

@Transactional
public int addThumbsUp(Map map) throws Exception{
int result = 0;
//如果调用其他方法执行sql,不进行回滚
// int addGroupPoint = this.addGradeGroupPoint(map);
// int addOrderedNumberByUserId = this.addOrderedNumberByUserId(map);
// int addPointNumberByUserId = this.addPointNumberByUserId(map);
// int createThumbsUp = this.createThumbsUp(map);

//在当前方法内执行sql,抛出RuntimeException 异常 回滚。
int addGroupPoint = this.template.update("ThumbsUp.addGradeGroupPoint",map);
int addOrderedNumberByUserId = this.template.update("ThumbsUp.addOrderedNumberByUserId",map);
int addPointNumberByUserId = this.template.update("ThumbsUp.addPointNumberByUserId",map);
int createThumbsUp = this.template.insert("ThumbsUp.createThumbsUp",map);

//如果记录为零,则认为失败
if(addOrderedNumberByUserId == 0){
throw new RuntimeException("失败");
}
if(addPointNumberByUserId == 0){
throw new RuntimeException("失败");
}
if(createThumbsUp == 0){
throw new RuntimeException("失败");
}
if(addGroupPoint == 0){
throw new RuntimeException("失败");
}

// result = ((addGroupPoint == 0 ? (addOrderedNumberByUserId == 0 ? 0 : ) : 0) == 0 ? 0 : addPointNumberByUserId) == 0 ? 0 : createThumbsUp;
// result = addGroupPoint == 0 ? 0 : (addOrderedNumberByUserId == 0 ? 0 : (addPointNumberByUserId == 0 ? 0 : (createThumbsUp == 0 ? 0 : createThumbsUp)))

if(addGroupPoint == 0 || addOrderedNumberByUserId == 0 || addPointNumberByUserId == 0 || createThumbsUp == 0){
result = 0;
}else{
result = 1;
}

return result;
}

mybatis 回滚记录

标签:insert   方法   addgroup   int   use   order   ddp   tran   upd   

原文地址:http://www.cnblogs.com/rwsren/p/7357111.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!