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. Ironic中pxe driver和agent driver的区别

    历史问题: 以pxe_ipmitool 和agent_ipmitool为例,看起来似乎前者不使用ironic-python-agent,后者使用,但是实际上两者都使用ironic-python-age ...

  2. linux memcached Session共享

    memcached memcached是高性能的分布式缓存服务器用来集中缓存数据库查询结果,减少数据库访问次数提高动态web应用的响应速度 传统web架构的问题许多web应用都将数据保存在RDBMS中 ...

  3. DM6446的Bootloader

    RBL(ARM ROM Boot Loader)在芯片出厂的时候就已经烧写到ROM里了,这不需要大家关心,上电后,RBL会自动从EMIFA EM_CS2 memory space (0x0200 00 ...

  4. dojo CsvStore简介

    dojox.data.CsvStore 作者:Jared Jurkiewicz 版本:V1.0 CsvStore是由dojo提供的简单的只读存储,并且是包含在dojox项目中的.CsvStore是读取 ...

  5. Linux显示机器的处理器架构

    Linux显示机器的处理器架构 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ arch x86_64 youhaidong@youhaidong-ThinkP ...

  6. org.hibernate.TransientObjectException:The given object has a null identifier

    1.错误描述 org.hibernate.TransientObjectException:The given object has a null identifier:com.you.model.U ...

  7. 微信开发中access_token,js_ticket,时间戳,签名生成工具

    Access_token生成工具 工具地址:https://mp.weixin.qq.com/debug 这个工具主要用来验证和生成微信公众号access_token,主要有正确的app_id和app ...

  8. 编写第一个Flutter App(翻译)

    博客搬迁至http://blog.wangjiegulu.com RSS订阅:http://blog.wangjiegulu.com/feed.xml 以下代码 Github 地址:https://g ...

  9. ArcGIS API for JavaScript 4.4 版本加载谷歌地图

    ArcGIS API for JavaScript 4.X 版本升级后,API发生了很大的变化. 其中就支持了WebEarth展示,主要是通过 esri/views/SceneView 实现的. 在新 ...

  10. Android中selector的使用

    第一种方法(强烈推荐) 方法:selector做遮罩,原图做background. 我们做按钮的时候经常需要用两个图片来实现按钮点击和普通状态的样式,这就需要提供两种图片,而且每个分辨率下还有多套图片 ...