mybatis返回list
1 Model类
public class Vo { /** * this is used for receive data partly from table user_question_section */ private Integer commonScore; private Integer questionSectionDef; /** * @return the commonScore */ public Integer getCommonScore() { return commonScore; } /** * @param commonScore the commonScore to set */ public void setCommonScore(Integer commonScore) { this.commonScore = commonScore; } /** * @return the questionSectionDef */ public Integer getQuestionSectionDef() { return questionSectionDef; } /** * @param questionSectionDef the questionSectionDef to set */ public void setQuestionSectionDef(Integer questionSectionDef) { this.questionSectionDef = questionSectionDef; } }
2.interface 接口类
List<Vo> selectUserSectionsScore(Integer userId);
3.mapper文件中
1.首先定义一个resultmap,type指向你的model类
<resultMap id="SectionDefAndScoreMap" type="com.kingland.otp.models.Vo"> <result column="score" jdbcType="INTEGER" property="commonScore"/> <result column="def_section_id" jdbcType="INTEGER" property="questionSectionDef"/> </resultMap>
2.select语句中,要用resultMap指明你定义的resultmap
<select id="selectUserSectionsScore" parameterType="INTEGER" resultMap="SectionDefAndScoreMap"> select usr.score,qs.def_section_id from ui.user_question_section_xref usr inner join ui.question_section qs on usr.question_section_id = qs.section_id where usr.user = #{0,jdbcType=INTEGER} </select>
4.完成
mybatis返回list的更多相关文章
- MyBatis 返回Map<String,Object>类型
<!-- 导出所有数据 --> <select id="exportAll" resultMap="map"> SELECT t1.ME ...
- Mybatis Mapper.xml 需要查询返回List<String>
当需要查询返回 List<String> <select id="getByIds" parameterType="java.lang.String&q ...
- 深入了解MyBatis返回值
深入了解MyBatis返回值 想了解返回值,我们须要了解resultType,resultMap以及接口方法中定义的返回值. 我们先看resultType和resultMap resultType和r ...
- 云笔记项目-MyBatis返回自增类型&堆栈对象补充理解
在云笔记项目中,讲到了MySql的自增,MyBatis查询到自增类型数据后可以设置返回到参数属性,其中学习了MySql的自增写法,堆栈对象等知识. MySql数据类型自增 建立一张Person表,其中 ...
- mybatis返回list很智能很简答的,只需要配置resultmap进行类型转换,你dao方法直接写返回值list<对应的object>就行了啊
mybatis返回list很智能很简答的,只需要配置resultmap进行类型转换,你dao方法直接写返回值list<对应的object>就行了啊 dao方法 public List< ...
- MyBatis 返回 List mapperxml怎么写
转: MyBatis 返回 List mapperxml怎么写? 原创 微wx笑 发布于2018-06-20 13:59:23 阅读数 10742 收藏 展开 有时候,我们不需要整个表的所有字段,而是 ...
- Mybatis,返回Map的时候,将Map内的Key转换为驼峰的命名
每次使用mybatis的时候,简单的连表查询,用Map接收的时候,都是像DB定义的字段一样,类似以下 student_name,student_id,没有转换为驼峰,但是又不能因为这一个定义一个jav ...
- mybatis返回map结果集
今天突发奇想,想用mybatis返回一个map结果集,结果我就整了一下午,不过终于解决了 1.如果你确定返回的数据只有一条,你可以这样整 xml中: <select id="searc ...
- Spring Boot将Mybatis返回结果转为驼峰的三种实现方式
本文不再更新,可能存在内容过时的情况,实时更新请访问原地址:Spring Boot将Mybatis返回结果转为驼峰的三种实现方式: 我们通常获取Mybatis返回的数据结果时想要将字段以驼峰的形式返回 ...
- mybatis拦截器 修改mybatis返回结果集中的字段的值
项目中使用了shardingJDBC,业务库做了分库,公共库没在一起,所以导致做码值转换的时候,需要在实现类里面做转码,重复的代码量大,故考虑用mybatis拦截器,将码值转换后再做返回给实现类. ...
随机推荐
- Qt Creator 整合 python 解释器教程
目录 1. 前言 2.前提条件 3.步骤 3.1 新建 python文件 3.2 编写 python 代码 3.3 配置 python 解释器 3.4 执行 python file 1. 前言 Pyt ...
- R语言数据框中,用0替代NA缺失值
1.用0替代数据框中的缺失值NA 生成数据框: > m <- matrix(sample(c(NA, :), , replace = TRUE), ) > d <- as.da ...
- Luogu P1747 好奇怪的游戏
题目背景 <爱与愁的故事第三弹·shopping>娱乐章. 调调口味来道水题. 题目描述 爱与愁大神坐在公交车上无聊,于是玩起了手机.一款奇怪的游戏进入了爱与愁大神的眼帘:***(游戏名被 ...
- MyBatis框架概述
MyBatis是一个优秀的持久层框架,它对jdbc的操作数据库的过程进行封装,使开发者只需要关注SQL本身,而不需要花费精力去处理例如注册驱动.创建connection.创建statement.手动设 ...
- GM8180_gpio内核模块调试
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h& ...
- DSP_TMS32F2812的串口操作
void scia_fifo_init(int ibaud) { SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback // No parit ...
- 讨论MMU
MMU是Memory Management Unit的缩写,中文名是内存管理单元,它是中央处理器(CPU)中用来管理虚拟存储器.物理存储器的控制线路,同时也负责虚拟地址映射为物理地址,以及提供硬件机制 ...
- linux下ssd电子盘速度检测
代码: #include<stdio.h> #include<sys/time.h> #include <fcntl.h> #include <pthread ...
- directshow filter中添加属性页
directShow 属性页的制作,为CBall filter加了一个属性页 具体为分以下步骤: 1.在要显示属性的类中继承现ISpecifyPropertyPages类,并实现此类的GetPages ...
- TypeError: Error #1009: 无法访问空对象引用的属性或方法
1.错误描述 TypeError: Error #1009: 无法访问空对象引用的属性或方法. at FirstMap/search_clickHandler()[E:\Flash Builder\M ...