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

级联查询

时间:2018-04-13 19:06:05      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:div   span   返回   sel   icon   查询   collect   oci   高度   

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

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

否则出现高度递归情况

级联查询

标签:div   span   返回   sel   icon   查询   collect   oci   高度   

原文地址:https://www.cnblogs.com/yangfei-beijing/p/8822620.html

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