springboot jpa 无法更新 生成insert语句

昨天遇到一个问题,使用saveAndFlush无法更新一个实体

@PostMapping("/edit")
    public ResultVO edit(@RequestBody TCommodity commodity){
        commodityRepository.saveAndFlush(commodity);
        return ResultVO.builder().code(1).message("").resultObject(commodity).build();
    "id":"4028338269a613820169a61406af0000",
    "commodityName":"百事可乐",
    "commodityDetails":"商品详情",
    "specification":"箱",
    "specificationCount":"24",
    "smallestUnit":"瓶",
    "singlePrice":"300",
    "groupPrice1":"280",
    "groupPrice2":"250",
    "sellerArea":"北京市",
    "sellerEntity":{
        "id":"37"

ID为主键,反复检查主键无误,但是hibernate生成的确实insert语句
跟踪源码后发现,save过程中检查数据是否存在,根据主键ID
,还包括version。

@Version
private Long version;

此时发现修改提交的实体中没有version字段,补上,提交成功

"id":"4028338269a613820169a61406af0000", "commodityName":"百事可乐", "commodityDetails":"商品详情", "specification":"箱", "specificationCount":"24", "smallestUnit":"瓶", "singlePrice":"300", "groupPrice1":"280", "groupPrice2":"250", "sellerArea":"北京市", "versiont":0, "sellerEntity":{