关联查询之map的延伸使用方法
<select id="front.sort.selectListall" parameterType="myshop.services.front.sort.bean.sort" resultMap="sortResultMap"> select one.*,tw.id sid,tw.catlevel slevel,tw.name sname,tw.code scode,thr.id tid,thr.catlevel tlevel,thr.name as tname, thr.code as tcode from tb_sort one join tb_sort tw on tw.pid=one.id join tb_sort thr on thr.pid=tw.id order by one.order1,tw.order1,thr.order1 </select> <resultMap id="sortResultMap" type="myshop.services.front.sort.bean.Sort"> <id property="id" column="id" /> <result property="catlevel" column="catlevel" /> <result property="code" column="code" /> <result property="name" column="name" /> <collection property="children" ofType="myshop.services.front.sort.bean.Sort"> <id property="id" column="sid" /> <id property="catlevel" column="slevel" /> <id property="code" column="scode" /> <id property="name" column="sname" /> <collection property="children" ofType="myshop.services.front.sort.bean.Sort"> <id property="id" column="tid" /> <id property="catlevel" column="tlevel" /> <id property="name" column="tname" /> <id property="code" column="tcode" /> </collection> </collection> </resultMap>
实体类接收数据:
private List<Sort> children;