myBatis中 collection 或 association 联合查询 中column 传入多个参数值
Posted 莫名字
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了myBatis中 collection 或 association 联合查询 中column 传入多个参数值相关的知识,希望对你有一定的参考价值。
下面是一个树形结构表自连接 联合查询 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 传入多个参数值的主要内容,如果未能解决你的问题,请参考以下文章
Mybatis之collection与association标签
Mybatis 高级结果映射 ResultMap Association Collection
Mybatis 高级结果映射 ResultMap Association Collection