Mybatis-Plus更新null值写法

2022-11-14 19:52:30 浏览数 (1)

有些业务要将某些字段更新位null值,但是又不能影响其它业务,就有了这篇文章。

一、写法

这样写就可以将这些字段置位null值。

代码语言:javascript复制
    @Override
    public boolean updateByIdCustome(HouseSpace houseSpace) {
        //return houseSpaceMapper.updateByIdCustome(houseSpace);
        LambdaUpdateWrapper<HouseSpace> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(HouseSpace::getSpaceId, houseSpace.getSpaceId());
        wrapper.set(HouseSpace::getCurrentMoisture, null);
        wrapper.set(HouseSpace::getMineral, null);
        wrapper.set(HouseSpace::getColorSmell, null);
        wrapper.set(HouseSpace::getWholeRiceGrains, null);
        wrapper.set(HouseSpace::getYellowGrain, null);
        wrapper.set(HouseSpace::getFattyacid, null);
        wrapper.set(HouseSpace::getCrudeFattyacid, null);
        wrapper.set(HouseSpace::getMucoriferous, null);
        wrapper.set(HouseSpace::getMildew, null);
        wrapper.set(HouseSpace::getImperfectGrain, null);
        wrapper.set(HouseSpace::getCompleteGrain, null);
        wrapper.set(HouseSpace::getProteinSolubilization, null);
        wrapper.set(HouseSpace::getDamageGrain, null);
        wrapper.set(HouseSpace::getGermination, null);
        wrapper.set(HouseSpace::getGluten, null);
        wrapper.set(HouseSpace::getHardness, null);
        wrapper.set(HouseSpace::getGrainHeight, null);
        wrapper.set(HouseSpace::getRemark, null);
        return this.update(wrapper);
    }

记录下笔记。

参考文章

https://blog.csdn.net/qq_43718048/article/details/125979551

0 人点赞