mybatis 一对多查询 collention标签

 

  
    //mapper中
    <resultMap id="BaseResultMap" 
        type="com.faceshow.modules.app.entity.AppActivityInfoEntity">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="is_deleted" property="deleted" jdbcType="TINYINT"
                typeHandler="com.faceshow.common.dao.TinyIntBooleanTypeHandler"/>
        <result column="share_img_url" property="shareImgUrl" jdbcType="VARCHAR"/>
        <result column="share_text_cn" property="shareTextCn" jdbcType="VARCHAR"/>
        <result column="share_text_en" property="shareTextEn" jdbcType="VARCHAR"/>
        <result column="float_icon_url" property="floatIconUrl" jdbcType="VARCHAR"/>

        //使用collention标签 映射  property 是表拆线呢出来的别名 
        //column是下边对应方法传入的值
        //ofType是返回值的类型List<String>
        //select 是定要执行的方法 结果集为实体类中定义的List<String>类型

        <collection property="likeImgUrl" column="id" ofType="java.lang.String"                     
          
        select="com.faceshow.modules.app.dao.AppLikeImgInfoDao.getAppActivityLikeImgUrl">
        </collection>

     </resultMap>

    //collection-select指定要执行的接口
    /**
     * @Author qkb
     * @Description // 查询活动对应的点赞图标
     * @Date 10:47 2018/11/21
     * @Param [activityId]
     * @return java.util.List<java.lang.String>
     **/
    List<String>  getAppActivityLikeImgUrl(Integer activityId);

    //指定执行的sql
    //#{activityId}是collection-column 传递的参数
    <!-- 查询获得东对应的点赞图标 -->
    <select id="getAppActivityLikeImgUrl" resultType="java.lang.String">
         SELECT like_img_url FROM app_activity_like_img WHERE activity_id = #{activityId}
    </select>

​n" property="shareTextEn" jdbcType="VARCHAR"/>
        <result column="float_icon_url" property="floatIconUrl" jdbcType="VARCHAR"/>

        //使用collention标签 映射  property 是表拆线呢出来的别名 
        //column是下边对应方法传入的值
        //ofType是返回值的类型List<String>
        //select 是定要执行的方法 结果集为实体类中定义的List<String>类型

        <collection property="likeImgUrl" column="id" ofType="java.lang.String"                     
          
        select="com.faceshow.modules.app.dao.AppLikeImgInfoDao.getAppActivityLikeImgUrl">
        </collection>

     </resultMap>

    //collection-select指定要执行的接口
    /**
     * @Author qkb
     * @Description // 查询活动对应的点赞图标
     * @Date 10:47 2018/11/21
     * @Param [activityId]
     * @return java.util.List<java.lang.String>
     **/
    List<String>  getAppActivityLikeImgUrl(Integer activityId);

    //指定执行的sql
    //#{activityId}是collection-column 传递的参数
    <!-- 查询获得东对应的点赞图标 -->
    <select id="getAppActivityLikeImgUrl" resultType="java.lang.String">
         SELECT like_img_url FROM app_activity_like_img WHERE activity_id = #{activityId}
    </select>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值