<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ezerbel.grain.service.edu.mapper.SubjectMapper"> <select id="selectNestedListByParentId" resultMap="nestedSubject"> select id,title,sort from edu_subject where parent_id = #{parentId} </select> <resultMap id="nestedSubject" type="com.ezerbel.grain.service.edu.entity.vo.SubjectVo"> <id property="id" column="id"/> <result property="title" column="title"/> <result property="sort" column="sort"/> <!-- select语句传入参数为cloumn对应的id --> <collection property="children" column="id" select="selectNestedListByParentId" ofType="com.ezerbel.grain.service.edu.entity.vo.SubjectVo"/> </resultMap> </mapper>