MyBatis(3.2.3) - Multiple results as a map
2016-03-01 17:05
183 查看
If we have a mapped statement that returns multiple rows and we want the results in a HashMap with some property value as the key and the resulting object as the value, we can use sqlSession.selectMap() as follows:
Here studentMap will contain studId values as keys and Student objects as values.
<select id=" findAllStudents" resultMap="StudentResult"> select * from Students </select> Map<Integer, Student> studentMap = sqlSession.selectMap("com.mybatis3.mappers.StudentMapper.findAllStudents", "studId");
Here studentMap will contain studId values as keys and Student objects as values.
相关文章推荐
- list 1
- zf
- mysql cmd导入数据库
- socket服务需要注意这两个头文件
- SpringMvc整合shiro报错(一)
- SystemUI->截屏
- Linux makefile 教程 非常详细,且易懂
- 通过node-mysql搭建Windows+Node.js+MySQL环境的教程
- c语言:用数组来处理求Fibonacci数列问题
- 移动端的数据库---SQLite3
- 前端的居中的问题
- 高性能网络编程总结及《TCP/IP Sockets编程(C语言实现) (第2版)》 代码下载(链接以及文件打包)
- Week6:Advice for Applying Machine Learning课后习题解答
- 物体的刚体组件Rigidbody component 详解
- 3.5 engine恢复备份时遇到的错误情况
- GitLab 之 Linux十分钟快装(转)
- linux中文语言包安装
- Java多线程(五)——Volatile关键字
- Spring 使用原生的jdbc或整合ORM操作数据库的模板编程
- java exception test