mybatis递归

public class IndustrialInfo {

    private String bigType;
    private List<Map> child;
    private String bigName;

    public String getBigType() {
        return bigType;
    }

    public void setBigType(String bigType) {
        this.bigType = bigType;
    }

    public List<Map> getChild() {
        return child;
    }

    public void setChild(List<Map> child) {
        this.child = child;
    }

    public String getBigName() {
        return bigName;
    }

    public void setBigName(String bigName) {
        this.bigName = bigName;
    }
}
<resultMap id="MenuResultMap" type="com.handsmap.CS.CS_ForeignScreen.domain.IndustrialInfo">
       <result column="bigName" jdbcType="VARCHAR" property="bigName" />
       <result column="bigType" jdbcType="VARCHAR" property="bigType" />
       <collection property="child" javaType="java.util.ArrayList" ofType="map" column="{bigType=bigType}" select="selectSmallResource" ></collection>
       <!--        第一个bigType对应传进来的参数#{bigType}-->
</resultMap>
<select id="selectIndustrialResource" parameterType="map"  resultMap="MenuResultMap">
     SELECT a.bigType,b.name as bigName,c.name as smallName FROM tb_industrial_resources_info a
     LEFT JOIN tb_dic_big_resource_type b on a.bigType=b.id
     LEFT JOIN tb_dic_small_resource_type c on a.smallType=c.id
     GROUP BY a.bigType
</select>

<select id="selectSmallResource" resultType="java.util.Map">
     SELECT b.name as smallName,count(*) as number FROM tb_industrial_resources_info a
     LEFT JOIN tb_dic_small_resource_type b on a.smallType=b.id
     where a.bigType=#{bigType}
     GROUP BY a.smallType
</select>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值