Statement returned more than one row, where no more than one was expected
Statement returned more than one row, where no more than one was expected
<resultMap id="Student" type="org.mybatis.example.Student">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="age" column="age"/>
</resultMap>
<resultMap id="InfoResult" type="org.mybatis.example.Student">
<id property="id" column="id" />
<result property="name" column="name" />
<result property="age" column="age" />
<association property="personalInfo" column="id" javaType="org.mybatis.example.PersonalInfo"
select="getPersonalInfo"/>
</resultMap>
<select id="getStudentInfo" parameterType="int" resultMap="InfoResult">
select * from student where id < #{id}
</select>
<resultMap id="PersonalInfo" type="org.mybatis.example.PersonalInfo">
<id property="id" column="id" />
<result property="height" column="height" />
<result property="weight" column="weight" />
</resultMap>
<!-- 选择学生的个人信息 -->
<select id="getPersonalInfo" parameterType="int" resultMap="PersonalInfo">
select * from personal_info where id < #{id}
</select>
下面是测试文件的片段
statement = "org.mybatis.mapping.studentMapper.getStudentInfo";
List<Student> students;
students = session.selectList(statement,2);
System.out.println(students.size());
for(int i=0; i<students.size(); i++) {
System.out.println(students.get(i).toString());
输入2时,返回结果为:
1
Student [name=张三, age=20, id=1, personalInfo=null]
输入3时,返回结果为:
2
Student [name=张三, age=20, id=1, personalInfo=null]
Student [name=李四, age=19, id=2, personalInfo=PersonalInfo [id=1, height=172, weight=67.2]]
输入4时,返回结果为
### Error querying database. Cause: org.apache.ibatis.executor.ExecutorException: Statement returned more than one row, where no more than one was expected.
### The error may exist in org/mybatis/mapping/studentMapper.xml
### The error may involve org.mybatis.mapping.studentMapper.getPersonalInfo
### The error occurred while handling results
### SQL: select * from personal_info where id < ?
我也是服了网上的这群哥哥们,所有的嵌套查询的例子都是输一个id,然后用`id = #{id}`这种条件来查询的,就没有其他的情况么???
Statement returned more than one row, where no more than one was expected的更多相关文章
- mybatis中:returned more than one row, where no more than one was expected.异常
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorEx ...
- 精尽MyBatis源码分析 - SQL执行过程(四)之延迟加载
该系列文档是本人在学习 Mybatis 的源码过程中总结下来的,可能对读者不太友好,请结合我的源码注释(Mybatis源码分析 GitHub 地址.Mybatis-Spring 源码分析 GitHub ...
- MyBatis关联查询和懒加载错误
MyBatis关联查询和懒加载错误 今天在写项目时遇到了个BUG.先说一下背景,前端请求更新生产订单状态,后端从前端接收到生产订单ID进行查询,然后就有问题了. 先看控制台报错: org.apache ...
- The command 'new_value' for SQLPlus
Format: column column_name new_value var_name Meaning: use the column_name of a select statment to c ...
- ERROR 1666 (HY000): Cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT = STATEMENT.
centos7.5 binlog恢复数据失败 问题: mysql> \. /tmp/inc.sql ERROR 1050 (42S01): Table 'new_1' already exist ...
- MySQL binlog_format (Mixed,Statement,Row)[转]
MySQL 5.5 中对于二进制日志 (binlog) 有 3 种不同的格式可选:Mixed,Statement,Row,默认格式是 Statement.总结一下这三种格式日志的优缺点. MySQL ...
- 直接放个DB2 SQL STATEMENT大全好了!
SQL statements This topic contains tables that list the SQL statements classified by type. SQL sch ...
- The Secrets of Oracle Row Chaining and Migration
from http://www.akadia.com/services/ora_chained_rows.html Overview If you notice poor performance in ...
- BINARY SEARCH in read table statement
1.for standard table, it must be sorted by search key. 2.for sorted table , binary search is used au ...
随机推荐
- 深入理解C++虚函数表
虚函数表是C++类中存放虚函数的一张表,理解虚函数表对于理解多态很重要. 本次使用的编译器是VS2013,为了简化操作,不用去操作函数指针,我使用到了VS的CL编译选项来查看类的内存布局. CL使用方 ...
- ceph命令
chen@admin-node:~$ ceph --help General usage: ============== usage: ceph [-h] [-c CEPHCONF] [-i INPU ...
- 连连看bug记录
1.bug统计 bug1: bug现象:消除两个相同图案之间的连线跨越了其他图片. 期待现象:应该改成绕过图案呈折线形. 二者差异:折现有没有穿过其他图片. bug原因猜测:小组能力原因. 复现步骤或 ...
- 腾讯QQ内测群新功能:QQ万人群即将袭来!
4月6日早晨有人爆出QQ群正在内部测试QQ万人群的消息,此消息一出,网友们都不蛋定了,各种议论纷纷,可是唯独腾讯没有做出任何有关这方面的解释. QQ是要准备让上万个人在一个群聊天吗? 那不会被刷屏刷死 ...
- inotify配合rsync实现文件同步
一.slave端rsync设置在此部署rsync服务和rsync daemon 1.安装rsync 2.配置rsyncd.conf文件#vi /etc/rsyncd.conf配置文件uid = r ...
- Android WebView常见问题及解决方案汇总
Android WebView常见问题解决方案汇总: 就目前而言,如何应对版本的频繁更新呢,又如何灵活多变地展示我们的界面呢,这又涉及到了web app与native app之间孰优孰劣的争论. 于是 ...
- Pinyin 输入法安装 opensuse 13 gnome
1 安装 拼音输入法 zypper in pinyin (scim 包含) 2 安装包 scim,scim-m17n,scim-pinyin,scim-qtimm,scim-tables,s ...
- 如何真正抓住微信小程序的红利? 阿禅知乎live总结
微信App定义 为满足用户某种开发需求.完全基于微信的消息或网页应用,入口是公众号,用户无需离开微信即可完成所有操作,所有需求都在公众号里被满足 微信App的优势 1. 顾客在哪里,就让顾客在哪里看到 ...
- spring设置webAppRootKey
今天一个同事来问webAppRootKey 在哪设置的 <context-param> <param-name>webAppRootKey</param-name> ...
- Oracle常用操作-----(一)
Oracle创建约束: ALTER TABLE 表名 ADD CONSTRAINT 约束名 约束内容. [注]Oracle中的default是一个值,而sql server中的default是一个约束 ...