我的编程空间,编程开发者的网络收藏夹
学习永远不晚

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

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

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

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

解决方式:使用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

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

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

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

解决方式:使用LambdaUpdateWrapper解决更新值为null的时候报错 public Integer updateExpenseWay(ProjectExpenseWayWayPo projectExpenseWayWayPo)
2023-08-17

win8.1 update升级失败怎么办?win8.1 update更新失败解决方法

遇到win8.1 update更新失败怎么办?下文将告诉大家win8.1 update升级更新失败解决方法,如果你在升级过程中不慎失败,其实解决方法很简单哦~大家按照下文操作即可。 解决方法(Win8.1平台):1、登录传统桌面,右击pyt
2023-06-04

Windows7自带Update更新系统失败该如何解决

一些Win7用户习惯使用系统自带的Update来更新系统,这种方法比较方便,但是很容易出现有时会更新失败,而有时却不会。这样便会使得系统重复安装更新,同时在历史记录列表也会出现许多的失败记录。该如何解决这个问android题呢?解决方法:首
2023-06-10

Mybatis-Plus中updateById方法不能更新空值问题解决

本文主要介绍了Mybatis-Plus中updateById方法不能更新空值问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
2022-11-13

win10更新失败cpu占用高如何解决

这篇“win10更新失败cpu占用高如何解决”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“win10更新失败cpu占用高如何
2023-07-01

Pycharm配置翻译插件Translation报错更新TTK失败不能使用怎么解决

这篇“Pycharm配置翻译插件Translation报错更新TTK失败不能使用怎么解决”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来
2023-06-30

使用mybatis执行SQL语句时有参数出现返回NULL值如何解决

今天就跟大家聊聊有关使用mybatis执行SQL语句时有参数出现返回NULL值如何解决,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。原来的写法: