zoukankan      html  css  js  c++  java
  • 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.完成

  • 相关阅读:
    JavaScript将数字转换为大写金额
    css浮动
    JS合并数组的几种方法及优劣比较
    jquery.zclip.js粘贴功能
    iframe获取元素
    某些框架,类库
    web前端基础知识!
    前端开发流程
    学习其他前端技术
    SVN的学习以及使用!
  • 原文地址:https://www.cnblogs.com/nelson-hu/p/6381679.html
Copyright © 2011-2022 走看看