当sqlserver设置flag后,代码执行报错怎么回滚

@GetMapping("/getWeight")
public List<Weight> callServiceB() {
    String url = "http://127.0.0.1:8866/sqlServer/getList";// [代码A] 假设服务 B 在 8081 端口上运行
    List<Weight> weights = new ArrayList<Weight>();
    ResponseEntity<List<Weight>> response = restTemplate.exchange(url, HttpMethod.POST, null, new ParameterizedTypeReference<List<Weight>>() {});
    weights = response.getBody();

    if(weights!=null && weights.size()>0){
        System.out.println("地磅数据入库");
        //装车出库
        wmTransactionDetailService.weightAutoStockOut(weights); // [代码B]
    }
    return weights;
}


代码A执行了sqlserver数据库更新操作,代码B报错,如何回滚?

发表回复