IllegalArgumentException,Mapped Statements collection does not contain value for xxxxx

IllegalArgumentException,Mapped Statements collection does not contain value for xxxxx,第1张

一、报错

第一个报错:

Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.dao.ClazzMapper.selectByPrimary

第二个报错:

###Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.dao.ScoresMapper.selectBystuid
###The error may exist in com/dao/StudentMapper.java (best guess)
###The error may involve com.dao.StudentMapper.selectByPrimaryKey
###The error occurred while handling results
###SQL: select * from student where id = ?
###Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.dao.ScoresMapper.selectBystuid

这两个错误都报的是 不合法的参数异常。映射语句中不包含xxx

二、分析

第一个错误说:映射语句集合不包含com.dao.ClazzMapper.selectByPrimary 的值。说明这个方法不在映射集合里面。仔细检查一下是不是方法名写错了。

第二个错误说:映射语句集合里不包含 com.dao.ScoresMapper.selectBystuid 这个值,而且指明错误是在执行这条语句时产生的 The error occurred while handling results ###SQL: select * from student where id = ?,然后自己仔细的对应了一下参数是否和实体类里的属性以及数据库里的字段相互对应,结果是因为数据库的字段写错了。

三、解决办法

目前自己先总结这两个错误,等之后遇到其他的再补充吧!

  1. 首先要检查一下方法名,看是不是方法获取错了,有没有这个方法
  2. 检查一下参数,将参数和数据库的字段以及实体类里的属性对应一下,看是不是写错了

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/743304.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-29
下一篇 2022-04-29

发表评论

登录后才能评论

评论列表(0条)

保存