• 级联查询


    <resultMap id="BaseResultMap" type="com.beta.cas.model.AuthModel">
            <id column="id" property="id" />
            <result column="name" property="name" />
            <result column="status" property="status" />
            <result column="levels" property="levels" />
            <result column="parent_id" property="parentId" />
            <result column="url" property="url" />
            <result column="show" property="show" />
            <result column="icon" property="icon" />
            <result column="sort" property="sort" />
            <result column="permission" property="permission" />
            <result column="creator_id" property="creatorId" />
            <result column="creator" property="creator" />
            <result column="create_time" property="createTime" />
            <result column="modify_id" property="modifyId" />
            <result column="modify_by" property="modifyBy" />
            <result column="modify_time" property="modifyTime" />
            <result column="app_id" property="appId" />
            <collection property="children" ofType="com.beta.cas.model.AuthModel" select="selectByParentId" column="id"></collection>
        </resultMap>
        <select id="findById" resultMap="BaseResultMap" parameterType="long">
            select * from auth where id = #{id}
        </select>
        <select id="findByAppId" resultMap="BaseResultMap">
            select * from auth where app_id = #{appId} and levels = #{levels} order by id
        </select>
        <select id="selectByParentId" resultMap="BaseResultMap">
            select am.* from auth am  where am.parent_id=#{parentId}
        </select>

    如果返回一个对象,可以增加

    <association property="parent" javaType="com.beta.cas.model.AuthModel" select="findById" column="parent_id"></association>

    如果返回一个集合,则必须去掉

    否则出现高度递归情况

  • 相关阅读:
    YAML语法
    Python tab补全
    Ubuntu开启root用户登录
    Windows部署JDK和Tomcat
    驾校宝典之科目一整理
    VMware之Red Hat安装配置部署
    H3C之VRRP实验部署
    Windows Server实验指导
    基础网络配置与管理综合实验报告
    H3C-VLan配置
  • 原文地址:https://www.cnblogs.com/yangfei-beijing/p/8822620.html
Copyright © 2020-2023  润新知