问题描述
@Transactionalpublic 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");则事务会回滚为什么?
解决方案
spring 默认的是针对发生运行时异常回滚,对检查异常不会滚,这是spring的特性,可以配置的
时间: 2025-01-02 03:10:44