org.apache.ibatis.binding.BindingException

 2023-02-25    357  

1、异常提示:

  org.apache.ibatis.binding.BindingException: Mapper method 'com.artup.dao.WorksDao.selectWorksIsCropCompletedById attempted to return null from a method with a primitive return type (byte).


2、原因:在使用 MyBatis 时,写了个查询语句,其返回值设置为了 byte 类型,当从数据库中能够查询到数据时,不会报错;当前查询不到数据时则会抛出此异常,是由于 null 不能够直接转换成 byte 类型导致的,我们可以将返回类型设置为对象 Byte,从而能够接收值为 null 的情况。



3、解决办法:

  3.1 将所有查询到的数据的值都设置为数字;

    或者
  3.2 将返回的类型由 byte 改成 Byte 从而能够接收 null 类型的值。

  

以上所述是小编给大家介绍的org.apache.ibatis.binding.BindingException,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!

org.apache.ibatis.binding.BindingException

原文链接:https://77isp.com/post/34442.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。