mybatisplus更新字段为null怎么处理?

mybatisplus更新字段为null怎么处理?

 
 
    /**
     * 主键
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;

    /**
     * 企业号
     */
    @ApiModelProperty(value = "企业号")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String sysOrgCode;
 

加上

@TableField(updateStrategy = FieldStrategy.IGNORED)

注意:使用时该字段必须传值,否则会更新为空。

 
//1、更新BUS_BILL_INFO_CUST
        BusBillInfoCust upBbc = new BusBillInfoCust();
        upBbc.setId(id);
        upBbc.setSysOrgCode(null);
        int num = busBillInfoCustMapper.updateById(upBbc);
        if (num == 0) {
            throw new JeecgBootException("更新BUS_BILL_INFO_CUST失败,请联系管理员");
        }
 

执行的sql为

 
update
    bus_bill_info_cust
set
    sys_org_code =null
where
    id ='953ea093ca1546c69b60d3a094d7d338'


posted @ 2023-04-22 18:46  binbinx  阅读(389)  评论(0编辑  收藏  举报