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的特性,可以配置的

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

报告相同问题?