![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
Mybatis
mybatis报错集锦
Yue-Chuan
自由生长
展开
-
Mybatis:Statement returned more than one row, where no more than one was expected
问题描述:在mybatis多对多查询中,出现了以下错误Statement returned more than one row, where no more than one was expected翻译:语句返回多行,其中不期望超过一行问题分析:出现这个问题,需要检查自己的多对多查询语句,以我的错误为例观察上图,是因为我需要查询是一对多,返回的结果是多条的,所以javaType应该指定为集合类型List.class如下:...原创 2021-11-04 22:01:11 · 1243 阅读 · 0 评论 -
mybatis注解方式实现模糊查询
问题描述:mybatis以注解方式开发时,想要实现模糊查询不能直接在sql上拼接,具体原因不详,当肯定的是mybatis无法获取到传入的动态数据拼接解决方案:使用concat()函数进行字符串拼接原创 2021-10-24 10:37:37 · 1218 阅读 · 0 评论 -
Mybatis中注解方式使用动态SQL拼接
问题描述:在Mybatis中以注解开发的方式使用动态sql拼接语句Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<if test='querySt原创 2021-10-23 15:56:05 · 1003 阅读 · 0 评论 -
Error instantiating interface com.yuechuan.dao.RoleDao with invalid types () or values ()
问题描述: mybatis错误,错误实例化接口与无效的类型或值。具体报错信息org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Error instantiating interface com.yuechuan.dao.RoleDao with invalid types () or原创 2021-05-11 15:55:22 · 411 阅读 · 1 评论 -
Mybatis一对多查询中集合只封装了一条数据
描述:一对多查询的时候,一条信息对应有多条数据,我们用集合来存储多的一方的数据。使用resultMap标签来定义封装的格式,今天在做测试时,出现集合内只封装到一条数据。原因:后面查阅资料得知,是因为两张表都有id字段,但是都没有讲明原因,我没有深究,但是猜测应该是因为查询的结果集有两个id字段,mybatis将主表的id值同时存到子表的id字段当读取第一行数据时因为不确定后面是否还有这个id的行返回,mybatis会将第一行存在Cahce类中,在读取第二行时,mybatis判断子表id值时发现值是一原创 2021-01-30 17:25:31 · 1592 阅读 · 3 评论 -
There is no getter for property named ‘str‘ in ‘class java.lang.String‘
问题描述:在运行查询方法时出现这个错误org.apache.ibatis.exceptions.PersistenceException:Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘str’ in ‘class java.lang.String’Cause: org.apache.ibatis.refl原创 2021-01-19 00:34:09 · 160 阅读 · 1 评论 -
Mybatis警告
在测试Mybatis的时候,出现了如下错误:WARNING: An illegal reflective access operation has occurredWARNING: Illegal reflective access by org.apache.ibatis.reflection.Reflector (file:/D:/ruanjian/Maven/maven_repository/org/mybatis/mybatis/3.4.5/mybatis-3.4.5.jar) to metho原创 2020-10-18 16:59:46 · 871 阅读 · 2 评论