MyBaits集合的嵌套 Select 查询

---恢复内容开始---

<resultMap id="slist" type="com.qujiali.model.AdShareInfo">
<id column="id_" property="id" />
<result column="type_" property="type" />
<result column="title_" property="title" />
<result column="content_" property="content" />
<result column="requirement_" property="requirement" />
<result column="link_url" property="linkUrl" />
<result column="reward_amount" property="rewardAmount" />
<result column="share_company" property="shareCompany" />
<result column="share_mode" property="shareMode" />
<result column="share_number" property="shareNumber" />
<result column="userShareEnable" property="userShareEnable" />
<result column="company_abbreviation" property="companyAbbreviation" />
<collection property="adImageContentList"
ofType="com.qujiali.model.AdShareImage" column="id_" select="adImageContentSel">
</collection>
<collection property="adImageRequireList"
ofType="com.qujiali.model.AdShareImage" column="id_" select="adImageRequireSel">
</collection>
</resultMap>
<resultMap type="com.qujiali.model.AdShareImage" id="adImageContentMap">
<result column="picture_url" property="pictureUrl" />
</resultMap>
<select id="findById" resultMap="slist"
parameterType="java.lang.Long">
select
g.*,
c.share_number,
ac.company_abbreviation
from
ad_share_info g
LEFT JOIN ad_company ac
ON g.share_company = ac.id_
LEFT JOIN ad_share_statistics c
ON g.id_ = c.share_id
WHERE g.id_ = #{id}
</select>
<select id="adImageContentSel" resultMap="adImageContentMap" parameterType="java.lang.Long">
select
f.picture_url
from ad_share_image f
where f.picture_type = '1'
and f.ad_share_id = #{id}
</select>
<select id="adImageRequireSel" resultMap="adImageContentMap" parameterType="java.lang.Long">
select
f.picture_url
from ad_share_image f
where f.picture_type = '2'
and f.ad_share_id = #{id}
</select>

---恢复内容结束---

转载于:https://www.cnblogs.com/Flying-Boy/p/10773629.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值