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

myBatis中 collection 或 association 联合查询 中column 传入多个参数值

时间:2016-06-30 14:30:12      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

 下面是一个树形结构表自连接 联合查询 Demo

 <resultMap id="BaseResultMap"  type="com.maidan.daas.entity.AccoSysmanResource" >
    <id column="pid" property="pid" jdbcType="INTEGER" />
    <result column="createTime" property="createtime" jdbcType="TIMESTAMP" />
    <result column="delete_flag" property="deleteFlag" jdbcType="INTEGER" />
    <result column="description" property="description" jdbcType="VARCHAR" />
    <result column="href" property="href" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="level" property="level" jdbcType="INTEGER" />
    <result column="resourceType" property="resourceType" jdbcType="INTEGER" />
    <result column="p_menu_id" property="pMenuId" jdbcType="INTEGER" />
    <result column="icon" property="icon" jdbcType="VARCHAR" />
  </resultMap>

<!--extends="BaseResultMap"   resultMap  相同列继承继承 -->

<resultMap type="com.maidan.daas.entity.AccoSysmanResource" id="ShopAccoSysmanResourceTree"  extends="BaseResultMap">
         <collection property="subResource"  javaType="ArrayList"
        column="pid" ofType="com.maidan.daas.entity.AccoSysmanResource">
             <id column="child_pid" property="pid" jdbcType="INTEGER" />
            <result column="child_createTime" property="createtime" jdbcType="TIMESTAMP" />
            <result column="child_delete_flag" property="deleteFlag" jdbcType="INTEGER" />
            <result column="child_description" property="description" jdbcType="VARCHAR" />
            <result column="child_href" property="href" jdbcType="VARCHAR" />
            <result column="child_name" property="name" jdbcType="VARCHAR" />
            <result column="child_level" property="level" jdbcType="INTEGER" />
            <result column="child_resourceType" property="resourceType" jdbcType="INTEGER" />
            <result column="child_p_menu_id" property="pMenuId" jdbcType="INTEGER" />
            <result column="child_icon" property="icon" jdbcType="VARCHAR" />
            <!-- 延迟加载 传递两个参数

    {pMenuId=child_pid,userId=userId}

     传递查询参数名称=字段名称

    -->
            <collection property="subResource"  javaType="ArrayList"  select="getShopChildAccoSysmanResource"
                column="{pMenuId=child_pid,userId=userId}" ofType="com.maidan.daas.entity.AccoSysmanResource" >
             </collection>
         </collection>
 </resultMap>

<select id="getShopChildAccoSysmanResource" parameterType="java.util.Map"  resultMap="BaseResultMap">

         select
        *
         from acco_sysman_resource where delete_flag = 0  
         AND p_menu_id=#{pMenuId,jdbcType=INTEGER}
         ANDuser_id = #{userId,jdbcType=INTEGER}

</select>

myBatis中 collection 或 association 联合查询 中column 传入多个参数值

标签:

原文地址:http://www.cnblogs.com/laotan/p/5629460.html

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