这是我遇到的问题的全写:

Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'providerName' of 'class com.smbms.pojo.Bill' with value 'Provider(id=null, proCode=null, proName=深圳市泰香米业有限公司, proDesc=null, proContact=null, proPhone=null, proAddress=null, proFax=null, createdBy=null, creationDate=null, modifyBy=null, modifyDate=null)' Cause: java.lang.IllegalArgumentException: argument type mismatch

这种情况下他还是可以查出部分结果的,但是还是会报错,下面这张图是我出现错误的控制台显示

解决办法

这个问题困扰了我一个下午才得以解决,其实是一个 collection 复杂类型集合下的 resultMap 标签的 type 写错了,因为我在实体类中将我的 providerName 定义为 String 类型,但是我却在 Type 中写成 com.smbms.pojo.Provider,这边导致了我的程序一直出现这个问题,尽管调试了很多别的地方也没有效果。

这个是我之前错误的代码:

<resultMap id="billList" type="com.smbms.pojo.Bill"><result property="billCode" column="billCode"></result><result property="productName" column="productName"></result><result property="providerName" column="proName"></result><result property="totalPrice" column="totalPrice"></result><result property="isPayment" column="isPayment"></result><result property="creationDate" column="creationDate"></result><association property="providerName" javaType="com.smbms.pojo.Provider" resultMap="provider"></association></resultMap><resultMap id="provider" type="com.smbms.pojo.Provider"><result property="proName" column="proName"></result></resultMap>

这个是我更改后的代码:

<resultMap id="billList" type="com.smbms.pojo.Bill"><result property="billCode" column="billCode"></result><result property="productName" column="productName"></result><result property="providerName" column="proName"></result><result property="totalPrice" column="totalPrice"></result><result property="isPayment" column="isPayment"></result><result property="creationDate" column="creationDate"></result><association property="providerName" javaType="com.smbms.pojo.Provider" resultMap="provider"></association></resultMap><resultMap id="provider" type="java.lang.String"><result property="proName" column="proName"></result></resultMap>

大家可以看到,在下面的 resultMap 标签的 type 中改为 java.lang.String,运行就成功了。

下面这张图是运行成功之后的结果,大家可以看到此时查出来的结果是完整的

不过令我感到疑惑的是,我把下面这条代码中的  javaType="com.smbms.pojo.Provider" 改为  javaType= " java.lang.String" 仍然是没有错误的,希望懂的小伙伴可以留言在评论区。

<association property="providerName" javaType="com.smbms.pojo.Provider" resultMap="provider"></association>

补充知识点

collection

复杂类型集合,一对多

内部嵌套,映射一个嵌套结果集到一个列表

属性        property:映射数据库列的实体对象的属性

ofType:完整Java类名或者别名(集合所包括的类型)

resultMap:引用外部resultMap

子元素        id

result        property:映射数据库列的实体对象的属性

column:数据库列名或者别名

错误类型:reflection.ReflectionException: Could not set property ‘xxx‘ of ‘class ‘xxx‘ with value ‘xxx‘相关推荐

  1. 使用mybatisplus的insert方法报错:org.apache.ibatis.reflection.ReflectionException: Could not set property

    使用mybatisplus的insert方法报错:org.apache.ibatis.reflection.ReflectionException: Could not set property 'i ...

  2. org.apache.ibatis.reflection.ReflectionException: There is no getter for property named XXX

    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti ...

  3. FAQ(31):org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ues

    进行Spring整合Mybatis时,发生的Bug: 看Log: org.mybatis.spring.MyBatisSystemException: nested exception is org. ...

  4. ?????nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for pr

    ?????nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...

  5. Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no gette

    这里写自定义目录标题 问题起因 错误码代码如下: step 1 问题起因 很简单的id和where mapper标签的使用不知道为什么突然出现无null1getter错误 错误码代码如下: org.a ...

  6. nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for propert

    nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for propert ...

  7. 错误类型3错误:活动类{}不存在

    本文翻译自:Error type 3 Error: Activity class {} does not exist I have an IntelliJ Android project, that ...

  8. Caused by: org.apache.ibatis.reflection.ReflectionException我碰到的情况,原因不唯一

    映射文件: <select id="selectKeyByUserId"  resultMap="Xxx">         <![CDATA ...

  9. org.apache.ibatis.reflection.ReflectionException: Error instantiating class with invalid types

    大家好,我是烤鸭,记录一个初级异常,百度搜索结果不多: Caused by: org.apache.ibatis.reflection.ReflectionException: Error insta ...

最新文章

  1. from selenium.webdriver.support.ui import Select
  2. Linux下统计当前文件夹下的文件个数、目录个数
  3. ant design pro取消登录_JeecgBoot实战按需加载 Ant-Design-Vue和Icon
  4. MongoDB基本操作(增删改查)
  5. 将select中的项从一个移动到另一个select中
  6. Win10快查、关闭开机自启动软件 - 教程篇
  7. React组件的State
  8. python 2.7 input_Python2.7-fileinput
  9. [转载]url带中文参数显示乱码的问题
  10. python 用户登录判断
  11. 基于PlayTennis数据集的决策树决策分析
  12. 一步一步实现 iOS 微信自动抢红包(非越狱)
  13. 企业内部即时通讯工具WorkPlus,支持内网私有化部署
  14. 【读书笔记】2018《后谷歌时代:大数据的衰落及区块链经济的崛起》
  15. 最新 iOS13 苹果登录
  16. 如何推广你的区块链初创企业,顺利完成ICO及后续发展
  17. Mesos 1.1.1 发布说明
  18. 沐阳Git笔记04查看版本演变历史
  19. 分治法:找出不合格银币
  20. 方便记忆的电话号码C语言

热门文章

  1. css中的BFC、IFC、GFC、FFC
  2. HPA控制器介绍以及实战案例
  3. [暑假]解决:开发分支拉错问题,比如我们在master修改成feature
  4. AI如何实现安全生产智能监控
  5. libgdx 处理加速传感器
  6. Gravity 的测试调研 Gravity - TiDB
  7. vue 传参获取数据
  8. 木马病毒:英国歌手Amy Winehouse临死前的最后影片,勿点
  9. 2021-5-8字符串作业
  10. 压力传感器电阻应变片的发展