zhengqx123456 2011-09-17 15:40
浏览 234
已采纳

spring 事务回滚

@Transactional
public Map routSave(RoutFormBean routbean) throws Exception{
Map result=new HashMap();
StringBuffer sb=new StringBuffer();
sb.append("delete from WfNrouteTbl where nrountePk.dnp_kbn='");
sb.append(routbean.getDnp());
sb.append("' and nrountePk.dep='");
sb.append(routbean.getDiv());
sb.append("' and nrountePk.rtno=");
sb.append(routbean.getRtno());
commonService.updateByHql(sb.toString());
if (1==1){
throw new Exception("asdfa");
}
}
如上事务中、事务不会回滚
如果改成
throw new RuntimeException("asdfa");
则事务会回滚
为什么?

  • 写回答

1条回答 默认 最新

  • lanshu111 2011-09-17 16:11
    关注

    spring 默认的是针对发生运行时异常回滚,对检查异常不会滚,
    这是spring的特性,可以配置的

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波