zhengqx123456
zhengqx123456
2011-09-17 15:40

spring 事务回滚

  • 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条回答

为你推荐

换一换