文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

mybatis-plus使用LambdaUpdateWrapper解决update更新null值失败解决

2023-08-17 05:51

关注

解决方式:使用LambdaUpdateWrapper解决更新值为null的时候报错

public Integer updateExpenseWay(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        LambdaUpdateWrapper qw = new LambdaUpdateWrapper<>();        qw.eq(BasePo::getId,projectExpenseWayWayPo.getId());        //下面是更新的字段          qw.set(projectExpenseWayWayPo::getProcessNum,projectExpenseWayWayPo.getProcessNum());        qw.set(projectExpenseWayWayPo::getExpenseWay,projectExpenseWayWayPo.getExpenseWay());        qw.set(projectExpenseWayWayPo::getHead,projectExpenseWayWayPo.getHead());        qw.set(projectExpenseWayWayPo::getActualAmount,projectExpenseWayWayPo.getActualAmount());        qw.set(projectExpenseWayWayPo::getHappenProve,projectExpenseWayWayPo.getHappenProve());        qw.set(projectExpenseWayWayPo::getFileName,projectExpenseWayWayPo.getFileName());        qw.set(projectExpenseWayWayPo::getFileUrl,projectExpenseWayWayPo.getFileUrl());        qw.set(projectExpenseWayWayPo::getFileUrls,projectExpenseWayWayPo.getFileUrls());        qw.set(projectExpenseWayWayPo::getFileNames,projectExpenseWayWayPo.getFileNames());        qw.set(projectExpenseWayWayPo::getUserAccount,projectExpenseWayWayPo.getUserAccount());        qw.set(projectExpenseWayWayPo::getSummary,projectExpenseWayWayPo.getSummary());        qw.set(projectExpenseWayWayPo::getApportNum,projectExpenseWayWayPo.getApportNum());        qw.set(projectExpenseWayWayPo::getUnitApportTotal,projectExpenseWayWayPo.getUnitApportTotal());        qw.set(projectExpenseWayWayPo::getShipNum,projectExpenseWayWayPo.getShipNum());        qw.set(projectExpenseWayWayPo::getRecoverAmount,projectExpenseWayWayPo.getRecoverAmount());        qw.set(projectExpenseWayWayPo::getStatement,projectExpenseWayWayPo.getStatement());        qw.set(projectExpenseWayWayPo::getState,projectExpenseWayWayPo.getState());        qw.set(projectExpenseWayWayPo::getRemark,projectExpenseWayWayPo.getRemark());        //this是在serviceImpl层指向的本类        boolean update = this.update(qw);        if (update){            return 1;        }        return 0;}

实体类

@Datapublic class BasePo >  extends Model{    private static final long serialVersionUID = 2366041360979353775L;    private Long id;    @TableField(fill = FieldFill.INSERT)    private String createUser;    @TableField(fill = FieldFill.INSERT_UPDATE)    private String updateUser;    @TableField(fill = FieldFill.INSERT)    @DateTimeFormat(pattern = "yyyy-MM-dd")    @JsonFormat(pattern = "yyyy-MM-dd")    private Date createTime;    @TableField(fill =FieldFill.INSERT_UPDATE)    @DateTimeFormat(pattern = "yyyy-MM-dd")    @JsonFormat(pattern = "yyyy-MM-dd")    private Date updateTime;}
@Data@TableName("T_PROJECT_EXPENSE_WAY_WAY")public class ProjectExpenseWayWayPo extends BasePo {    private Long initiaId;    private Long expenseId;    private Long expenseWayId;    @ImportIndex(index = 0)    private String processNum;    @ImportIndex(index = 1)    private String expenseWay;    @ImportIndex(index = 2)    private String head;    @ImportIndex(index = 3)    private Integer actualAmount;    @ImportIndex(index = 4)    private String happenProve;    private String fileName;    private String fileUrl;    private String fileNames;    private String fileUrls;    private String userAccount;    @ImportIndex(index = 5)    private String summary;    @ImportIndex(index = 6)    private Integer apportTotal;    @ImportIndex(index = 7)    private Integer apportNum;    private Double unitApportTotal;    @ImportIndex(index = 8)    private Integer shipNum;    private Double recoverAmount;    private String statement;    private String state;    @ImportIndex(index = 9)    private String remark;    public Object getActualAmount(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getState(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getProcessNum(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getExpenseWay(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getHead(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getHappenProve(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getFileName(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getFileUrl(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getUserAccount(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getSummary(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getApportNum(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getUnitApportTotal(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getShipNum(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getRecoverAmount(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getStatement(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getRemark(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getFileUrls(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }    public Object getFileNames(ProjectExpenseWayWayPo projectExpenseWayWayPo) {        return projectExpenseWayWayPo;    }}

appliacation.yml 配置

在application.yml 配置mybatis-plus:  mapper-locations: >-    classpath: com/battery/third/department/dao/*.xml    //插入的值有null, Cause: java.sql.SQLException: 无效的列类型: 1111,要配  configuration:    jdbc-type-for-null: "null"

来源地址:https://blog.csdn.net/qq_50990884/article/details/129384409

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯