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的更多相关文章

  1. MyBatis 返回Map<String,Object>类型

    <!-- 导出所有数据 --> <select id="exportAll" resultMap="map"> SELECT t1.ME ...

  2. Mybatis Mapper.xml 需要查询返回List<String>

    当需要查询返回 List<String> <select id="getByIds" parameterType="java.lang.String&q ...

  3. 深入了解MyBatis返回值

    深入了解MyBatis返回值 想了解返回值,我们须要了解resultType,resultMap以及接口方法中定义的返回值. 我们先看resultType和resultMap resultType和r ...

  4. 云笔记项目-MyBatis返回自增类型&堆栈对象补充理解

    在云笔记项目中,讲到了MySql的自增,MyBatis查询到自增类型数据后可以设置返回到参数属性,其中学习了MySql的自增写法,堆栈对象等知识. MySql数据类型自增 建立一张Person表,其中 ...

  5. mybatis返回list很智能很简答的,只需要配置resultmap进行类型转换,你dao方法直接写返回值list<对应的object>就行了啊

    mybatis返回list很智能很简答的,只需要配置resultmap进行类型转换,你dao方法直接写返回值list<对应的object>就行了啊 dao方法 public List< ...

  6. MyBatis 返回 List mapperxml怎么写

    转: MyBatis 返回 List mapperxml怎么写? 原创 微wx笑 发布于2018-06-20 13:59:23 阅读数 10742 收藏 展开 有时候,我们不需要整个表的所有字段,而是 ...

  7. Mybatis,返回Map的时候,将Map内的Key转换为驼峰的命名

    每次使用mybatis的时候,简单的连表查询,用Map接收的时候,都是像DB定义的字段一样,类似以下 student_name,student_id,没有转换为驼峰,但是又不能因为这一个定义一个jav ...

  8. mybatis返回map结果集

    今天突发奇想,想用mybatis返回一个map结果集,结果我就整了一下午,不过终于解决了 1.如果你确定返回的数据只有一条,你可以这样整 xml中: <select id="searc ...

  9. Spring Boot将Mybatis返回结果转为驼峰的三种实现方式

    本文不再更新,可能存在内容过时的情况,实时更新请访问原地址:Spring Boot将Mybatis返回结果转为驼峰的三种实现方式: 我们通常获取Mybatis返回的数据结果时想要将字段以驼峰的形式返回 ...

  10. mybatis拦截器 修改mybatis返回结果集中的字段的值

    项目中使用了shardingJDBC,业务库做了分库,公共库没在一起,所以导致做码值转换的时候,需要在实现类里面做转码,重复的代码量大,故考虑用mybatis拦截器,将码值转换后再做返回给实现类.   ...

随机推荐

  1. 左连接条件与where条件的区别

    Sql 查询语句应用左连接时的链接条件中经常加一些常量值在里面如: "On a.id= b.id and b.is_del =0 and b.is_old =1" 这种条件如果加在 ...

  2. linux web服务器及LAMP动态网站平台搭建

    (vim补:)vim另存为:x,x w 目标文件路径vim批量删除x:x,x d Web服务:基于B/S架构的web通信服务端:支持HTTP协议的网页提供程序客户端:按标记规范显示网页的浏览器程序客户 ...

  3. Linux下安装MySQL数据库(压缩包方式安装)

    1.这里我将Mysql安装在/usr/local/mysql目录里面,也可以安装在其他地方; mkdir /usr/local/mysql 2.下载MySQL压缩包 wget http://dev.M ...

  4. DirectDraw用到的DDSURFACEDESC2

    DDSURFACEDESC2 结构定义一个需求的平面.下面的例子演示了结构的定义和标志位的设定: // Create the primary surface with one back buffer. ...

  5. FusionCharts封装-Category

    Categories.java: /** * @Title:Categories.java * @Package:com.fusionchart.model * @Description:Fusion ...

  6. STM32F4 串口实验中收不到超级终端发送的数据,调试工具却可以

    我用串口精灵发送数据没有问题,但是接收数据没反应. 串口接受的时候必须要用中断的,你发送只靠单一的标志位是可以判断的,但是接受的时候,你是一直停留在while里面,我们判断接受是否完成,通过检测是否收 ...

  7. g++基本用法

    用法:g++[选项]文件... g++编译流程: main.cxx #include <iostream> using namespace std; int main(void) { co ...

  8. windows下键盘常用快捷键整理

    以下快捷键均在win7环境下测试有效: 声明:本博文由多篇博文经实测整理而出. win键相关的快捷键多用于桌面场景,如开起资源管理器.切换任务窗口.最大化最小化窗口等等. 场景一: 1. 任何情况下想 ...

  9. hibernate学习(一)配置,导包

    框架的作用 学过javaWeb基础的已经对web层 jsp  servlet   ,service  层  ,dao层的jdbc .DBUtils 有了很深的了解 并编写代码实现某种功能 为了提高开发 ...

  10. Eclipse远程debug服务器

    一,找端口号 二,Eclipse配置 三,测试是否成功 四,结束远程debug