码迷,mamicode.com
首页 > 其他好文 > 详细

MyBaits集合的嵌套 Select 查询

时间:2019-04-26 12:58:22      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:查询   ict   find   cti   --   lin   share   result   users   

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

<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>

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

MyBaits集合的嵌套 Select 查询

标签:查询   ict   find   cti   --   lin   share   result   users   

原文地址:https://www.cnblogs.com/Flying-Boy/p/10773629.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!