Cause: org.apache.ibatis.type.TypeException:Error setting null for parameter #1 with JdbcType OTHER

MybatisPlus采用updateById更新数据抛异常:Cause: org.apache.ibatis.type.TypeException:Error setting null for parameter #1 with JdbcType OTHER

情景:Spring-SpringMVC-Mybatisplus,采用MybatisPlus的selectOne方法查询出数据,此数据某个字段值为null,修改了该数据除了该空值的其他几个字段,之后采用MybatisPlus的updateById方法更新,抛出异常

例如:

Account account = service.selectOne(xxx);//采用MybatisPlus的selectOne方法查询数据,其中字段Phone值为null

String mail = request.getParameter(xxx);//需要修改的参数

account.setMail(mail);

boolean flag = service.updateById(account);//采用MybatisPlus的updateById方法,抛出异常

解决:

1、新建mybatis-config.xml,在配置数据库的xml中引入该xml

mybatis-config.xml

配置数据xml部分

2、不需要新建xml文件,直接在配置数据库的xml中配置

相关内容

MybatisPlus采用updateById无法更新空值或者null:https://mp.csdn.net/postedit/98588479

官网解决:https://mp.baomidou.com/guide/faq.html#cause-org-apache-ibatis-type-typeexception-error-setting-null-for-parameter-1-with-jdbctype-other

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值