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. 内置函数--global() 和 local()

    一 . globals :返回当前作用域内全局变量的字典.   >>> globals() {'__spec__': None, '__package__': None, '__bu ...

  2. eclipse调试hadoop2.2.0源码笔记

    在hadoop1.x版本时使用的是在Windows下编译Eclipse插件,远程调试集群.换成2.2.0,没有eclipse-plugin文件. hadoop2.2.0"远程调试集群&quo ...

  3. java线程池技术(二): 核心ThreadPoolExecutor介绍

    版权声明:本文出自汪磊的博客,转载请务必注明出处. Java线程池技术属于比较"古老"而又比较基础的技术了,本篇博客主要作用是个人技术梳理,没什么新玩意. 一.Java线程池技术的 ...

  4. 基于Jenkins+Git+Gradle的Android持续集成

    本文参考了: http://my.oschina.net/uboluo/blog/157483 http://java.dzone.com/articles/automating-continuous ...

  5. WebService之CXF注解之五(配置文件)

    1.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version=" ...

  6. 关于游览器网页标题logo的设置

    <link rel="shortcut icon"type="image/x-icon" href="images/favicon.ico&qu ...

  7. UEFI模式 Thinkpad t470p Ubuntu 16.04 LTS

    准备阶段 使用官方推荐的Rufus制作U盘启动盘 在Windows 10系统下压缩出来一些空间(60G),不要分配盘符 系统设置 在Bios中关闭secure boot (设置为Disenabled) ...

  8. Shell 的特殊变量

    2017-08-02 1.$0 获取当前脚本的名称或全路径 cat name.sh Linux shell sh name.sh echo $0 name.sh 2.$n(n >=1) 获取脚本 ...

  9. Java中使用UDP实现简单的聊天功能

    通过DatagramSocket类来实现.此类表示用来发送和接收数据报包的套接字. 发送端代码如下: import java.io.IOException; import java.net.*; im ...

  10. Spring AOP介绍

    1.介绍 AOP(面向切面编程)对OOP(面向对象编程)是一种补充,它提供了另一种程序结构的思路.OOP的模块单元是class,而AOP的模块单元是aspect.Spring中一个关键的组件是AOP框 ...