zl程序教程

您现在的位置是:首页 >  工具

当前栏目

已解决nested exception is org.apache.ibatis.exceptions.PersistenceException

Apache 解决 is org Exception nested ibatis exceptions
2023-09-27 14:27:33 时间

已解决nested exception is org.apache.ibatis.exceptions.PersistenceException

在这里插入图片描述

报错问题

粉丝群里面的一个小伙伴敲代码时发生了报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错信息如下:

"nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.IndexOutOfBoundsException: Index: 6, Size: 6
### The error may exist in file [D:\\synda\\yyy-app\\api-app\\synda-oauth\\target\\classes\\mapper\\AuthRoleMapper.xml]
### The error may involve com.tengyun.oauth.mapper.AuthRoleMapper.getRole
### The error occurred while handling results
### SQL: SELECT r.id,r.name,r.role_code AS roleCode,r.data_auth AS dataAuth,r.state,r.pid FROM auth_user_role ur         LEFT JOIN auth_role r ON r.id=ur.role_id         WHERE ur.user_id=?         GROUP BY r.id ORDER BY r.data_auth
### Cause: java.lang.IndexOutOfBoundsException: Index: 6, Size: 6"

在这里插入图片描述

解决方法

解决方法如下

在这里插入图片描述
报错内容说 你的 mapper.xml 文件中的某个查询有错,
仔细看你的 sql、映射规则、代码是否有错,
那么请在你在返回的实体类中加入一个空的构造方法,因为我们的实体类里面加了一个有参构造函数,空的构造函数被覆盖,mybatist-plus中 的 resultType=“com.tengyun.oauth.entity.AuthRole”,去调用了我们空的构造函数,结果没有

福利

每周会送6本技术书籍包邮到家
由于博主时间精力有限,每天私信人数太多,没办法每个粉丝都及时回复
大家可以进社区裙或者添加博主微信
点击下方链接即可
http://t.csdn.cn/6kInJ