mybatis中resultMap标签中collection标签的嵌套使用

更新时间:2023-07-22 15:09:48 阅读: 评论:0

mybatis中resultMap标签中collection标签的嵌套使⽤mybatis中resultMap标签中collection标签的嵌套使⽤
场景
技能管理需要划分为
⼤类技能 (eg:演绎类)
⼦分类技能(eg:⽩蛇传)
技能(eg:⽩蛇技能、青蛇技能等)
表关系如下
⼤类—⼦类—技能
数据结构如下
"list":{
"classifySkillId":"eu",
"classifySkillName":"eiusmod cupidatat d",
人操人摸
"asmbleSkillLists":[
{
"asmbleSkillId":"incididunt ea es ad",
"asmbleSkillName":"adipisicing",
"nameSkillLists":[
{
"nameSkillId":"cupidatat",
"nameSkillName":"dolor aute dolor ut Duis"
},
{
"nameSkillId":"conctetur non dolore velit",
绑定英文
"nameSkillName":"Duis minim fugiat magna"
}
]
}
]
}
pojo类
@Data
public class SkillsManagerVo {
private String classifySkillId;
private String classifySkillName;
private List<AsmbleSkillListPo> asmbleSkillLists;
}
@Data
电脑开机时间查询public class AsmbleSkillListPo {
private String asmbleSkillId;
private String asmbleSkillName;
private List<NameSkillPo> nameSkillLists;
}
@Data
@TableName("name_skill")
化学行业
@AllArgsConstructor
@NoArgsConstructor
全屏手写public class NameSkillPo {
/**技能id*/
private String nameSkillId;
/**技能名称*/
private String nameSkillName;
/**⼦分类技能id*/
private String asmbleSkillId;
/**是否删除*/
private Integer deleted;
}
微信农场
查询的sql语句
<lect id="querySkills"resultMap="queryClassifySkills">
SELECT DISTINCT
s.classify_skill_id,
s.classify_skill_name,
s.asmble_skill_id,
s.asmble_skill_name,
ss.name_skill_id,
ss.name_skill_name
FROM
(
SELECT DISTINCT
cs.classify_skill_id,
cs.classify_skill_name,
asl.asmble_skill_id,
asl.asmble_skill_name
FROM
classify_skill cs
LEFT JOIN asmble_skill asl ON cs.classify_skill_id = asl.classify_skill_id
WHERE
cs.deleted = 0
AND asl.deleted = 0
ORDER BY
cs.classify_skill_id
) s
LEFT JOIN (
SELECT DISTINCT
年份五行
asl.asmble_skill_id,
asl.asmble_skill_name,
name_skill_id,
name_skill_name
FROM
asmble_skill asl
怎样才能变帅LEFT JOIN name_skill ns ON asl.asmble_skill_id = ns.asmble_skill_id
WHERE
asl.deleted = 0
AND ns.deleted = 0
ORDER BY
asl.asmble_skill_id
) ss ON s.asmble_skill_id = ss.asmble_skill_id
</lect>
resultMap的写法:collection标签中再嵌套collection就可以完成⼆级以上的集合嵌套;
<resultMap id="queryClassifySkills"type="entity.skillsmanager.vo.SkillsManagerVo">
<result column="classify_skill_id"property="classifySkillId"/>
<result column="classify_skill_name"property="classifySkillName"/>
<collection property="asmbleSkillLists"javaType="list"resultMap="nameSkills"
ofType="entity.skillsmanager.po.AsmbleSkillListPo"/>
</resultMap>
<resultMap id="nameSkills"type="entity.skillsmanager.po.AsmbleSkillListPo">
<result column="asmble_skill_id"property="asmbleSkillId"/>
<result column="asmble_skill_name"property="asmbleSkillName"/>
<collection property="nameSkillLists"javaType="list"ofType="entity.skillsmanager.po.NameSkillPo"> <result column="name_skill_id"property="nameSkillId"/>
<result column="name_skill_name"property="nameSkillName"/>
</collection>
</resultMap>
rty=“nameSkillId”/>

本文发布于:2023-07-22 15:09:48,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1110987.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:技能   查询   标签   电脑   时间
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图