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拦截器,将码值转换后再做返回给实现类. ...
随机推荐
- Ansible自动化运维笔记3(playbook)
1.基本语法 playbook文件格式为yaml语法.示例如下: 1.1 nginx.yaml --- - hosts: all tasks: - name: Install Nginx Packag ...
- 【DDD】领域驱动设计实践 —— 一些问题及想法
在社区系统的DDD实践过程中,将遇到一些问题和产生的想法记录下来,共讨论. 本文为[DDD]系列文章中的其中一篇,其他内容可参考:使用领域驱动设计思想实现业务系统. 1.dto.model和entit ...
- 芝麻HTTP:代理的基本原理
我们在做爬虫的过程中经常会遇到这样的情况,最初爬虫正常运行,正常抓取数据,一切看起来都是那么美好,然而一杯茶的功夫可能就会出现错误,比如403 Forbidden,这时候打开网页一看,可能会看到&qu ...
- layer与iframe 间值的相互传递
在A页添加 <input id="handle_status" value="" hidden="hidden"> jq代码 l ...
- 【HNOI 2002 】营业额统计(splay)
题面 Description Tiger最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况. Tiger拿出了公司的账本,账本上记录了公司成立以来每天的营 ...
- 【SDOI2009】HH去散步(矩阵快速幂)
题面 题目描述 HH有个一成不变的习惯,喜欢饭后百步走.所谓百步走,就是散步,就是在一定的时间 内,走过一定的距离. 但是同时HH又是个喜欢变化的人,所以他不会立刻沿着刚刚走来的路走回. 又因为HH是 ...
- LightOJ1341 Aladdin and the Flying Carpet
题意 给一对数字 a,b ,a是一个长方形的面积,问有多少种整数的边的组合可以组成面积为a的长方形,要求最短的边不得小于b 数据组数T<=4000, a,b<=10^12 Solution ...
- poi导入Excel,数字科学记数法转换
在这里分享一下使用poi 导入Excel时 把数字转换为科学记数法的解决方法: 就是使用DecimalFormat对 i 进行了格式化 结果为:
- js监听input输入框值的实时变化实例
情景:监听input输入框值的实时变化实例 解决方法:1.在元素上同时绑定oninput和onporpertychanger事件 实例:<script type="text/JavaS ...
- ThreadLocal用例之周期为一次请求的变量
public class RecordedLocal { private static ThreadLocal<Recorded> local = new ThreadLocal<R ...