• Mybatis 使用 SQL 递归获取单表中的树结构


    • xml 代码
    <resultMap type="xxx.xxx.xxx.xxx.实体类" id="xxxListTree">
            <result column="id" property="id" javaType="java.lang.Long" />
            <result column="xxx_name" property="xxxName" javaType="java.lang.String" />
            <result column="parent_id" property="parentId" javaType="java.lang.Long" />
            <result column="create_user" property="createUser" javaType="java.lang.Long" />
    <!--        <collection column="{id=id,currentUserId=create_user}" property="xxxxListDtoList" ofType="com.cloud.datasynergy.model.xxxxListDto" javaType="java.util.ArrayList" select="selectXxxxXXXrenById"/>-->
            <collection autoMapping="true" column="{id=id,currentUserId=create_user}" javaType="ArrayList" ofType="xxx.xxx.xxx.xxx.实体类" property="实体类里面的list集合,用于存储子节点数据" select="selectXxxxXxxxrenById">
            </collection>
        </resultMap>
    
    
    <select id="selectXxxxList" resultMap="xxxListTree">
            select * from t_Xxxx_list where parent_id = #{id} and create_user = #{currentUserId} and is_del = 0
        </select>
    
    
    <select id="selectXxxxXXXrenById" resultMap="xxxListTree">
            select * from t_Xxxx_listwhere parent_id = #{id} and create_user = #{currentUserId} and is_del = 0
        </select>
    
    • 如何在递归是传递多个参数
    column="{id=id,currentUserId=create_user}"
    
    > =左边代表 dao or mapper 中的参数,=右边代表数据库表中的字段
  • 相关阅读:
    $().click()和$(document).on("click","selector",function(){})的区别
    orm 常用字段及参数
    前端vue 跨组件传参,cokies,axion
    drf 异常 响应 解析 三大模块
    drf 视图家族
    表断关系,和modlesserializers序列化,反序列化
    drf ___jwt插件
    drf 排序过滤分页
    django drf cors 跨域问题
    redis 数据库
  • 原文地址:https://www.cnblogs.com/gaofangye/p/12575885.html
Copyright © 2020-2023  润新知