mybatis-plus的collection、association 标签传递多参数

2020-09-07 09:59:16 浏览数 (1)

常规示例:

代码语言:javascript复制
<resultMap type="com.zxsl.air.business.entity.dto.PsControlo3noticeDto" id="psControlo3noticeDto">
        <id column="id" property="id"/>
        <collection  property="fileInfoDtos" select="getFileInfoDtos" column="id"
                     ofType="com.zxsl.air.platform.upload.dto.FileInfoDto" javaType="java.util.ArrayList">
        </collection >
        <collection  property="psControlo3industrys" select="getpsControlo3industrys" column="id"
                     ofType="com.zxsl.air.business.entity.dto.PsControlo3industryDto" javaType="java.util.ArrayList">
        </collection >
    </resultMap>

有些时候需要传递往collection、association 标签传递多参数,可通过如下方式: 修改column属性如column="{id=idvalue,industry=industryvalue,name=namevalue}"

代码语言:javascript复制
<resultMap type="com.zxsl.air.business.entity.dto.PsControlo3noticeDto" id="psControlo3noticeDto">
        <id column="id" property="id"/>
        <collection  property="fileInfoDtos" select="getFileInfoDtos" column="id"
                     ofType="com.zxsl.air.platform.upload.dto.FileInfoDto" javaType="java.util.ArrayList">
        </collection >
        <collection  property="psControlo3industrys" select="getpsControlo3industrys" column="{id=id,industry=industry,name=name}"
                     ofType="com.zxsl.air.business.entity.dto.PsControlo3industryDto" javaType="java.util.ArrayList">
        </collection >
    </resultMap>

其中idvalue、industryvalue、namevalue可不声明<id column="id" property="id"/>,i但是idvalue、industryvalue、namevalue必须是sql查询的返回列,也可以是某些常量列。

代码语言:javascript复制
<select id="getList" parameterType="com.zxsl.air.business.controller.param.QueryPsControlo3noticeParam" resultMap="psControlo3noticeDto">
select distinct pcn.*,pci.controlO3Notice_id,
queryPsControlo3noticeParam.industry as industry      
from ps_controlo3notice pcn
<select>

本文笔记到此结束。

0 人点赞