Connection conn = null; try { conn = queryRunner.getDataSource().getConnection(); ConnectionUtils.setAutoCommit(conn, false); aa.save(); bb.save(); ConnectionUtils.commit(conn); } catch (SQLException e) { log.error("e", e); ConnectionUtils.rollback(conn); ret.set(-1, "系统异常"); } finally { ConnectionUtils.setAutoCommit(conn, true); ConnectionUtils.closeConnection(conn); } return ret;
说明:aa保存失败,或者bb保存失败,则全部回滚,只有两个全部成功,才成功