概述
多层集合嵌套返回结果用resultMap,collection中再次使用resultMap
<resultMap id="chainVo" type="com.suncnpap.intelligentqa.vo.ChainVo">
<id column="cid" property="id"/>
<result column="access_key" property="accessKey"/>
<result column="secret_key" property="secretKey"/>
<result column="outer_chain_name" property="outerChainName"/>
<result column="outer_chain_document" property="outerChainDocument"/>
<collection property="intentionVos" ofType="com.suncnpap.intelligentqa.vo.ChainIntentionVo"
resultMap="intentionVos"/>
</resultMap>
<resultMap id="intentionVos" type="com.suncnpap.intelligentqa.vo.ChainIntentionVo">
<id column="iid" property="id"/>
<result column="intention_name" property="intentionName"/>
<collection property="questionVoList" ofType="com.suncnpap.intelligentqa.vo.MultiQuestionVo">
<id column="qid" property="id"/>
<result column="question" property="question"/>
</collection>
<collection property="wordVos" ofType="com.suncnpap.intelligentqa.vo.ChainIntentionWordVo">
<id column="wid" property="id"/>
<result column="word_slot" property="wordSlot"/>
<result column="word_slot_miss_question" property="wordSlotMissQuestion"/>
<result column="entity_type_ids" property="entityTypeIds"/>
</collection>
</resultMap>
<select id="detail" resultMap="chainVo">
select tc.id as tid,
tci.id as iid,
tciw.id as wid,
tmq.id as qid,
access_key,
secret_key,
outer_chain_name,
outer_chain_document,
intention_name,
question,
word_slot,
word_slot_miss_question,
entity_type_ids
from t_chain tc
left join t_chain_intention tci on tc.id = tci.chain_id
left join t_chain_intention_word tciw on tci.id = tciw.intention_id
left join t_multi_question tmq on tci.id = tmq.parent_id
where tc.id = #{id}
and tc.deleted = 0
</select>
最后
以上就是怕黑小海豚为你收集整理的mybatis多表联查,返回结果嵌套list的全部内容,希望文章能够帮你解决mybatis多表联查,返回结果嵌套list所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复