mybatis-plus使用LambdaUpdateWrapper解决update更新null值失败解决
短信预约 -IT技能 免费直播动态提醒
解决方式:使用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