1.映射
<!--app返回结果封装--> <resultMap id="AppMap" type="java.util.HashMap"> <!--不加这个映射 返回无id--> <id column="id" jdbcType="BIGINT" property="id" /> <collection property="childsList" column="id" select="getChildrenModues"> </collection> </resultMap>
2.sql
<select id="commentList" parameterType="java.lang.Long" resultMap="AppMap"> SELECT a.`id` as id,a.`username` AS username,a.`create_time` AS createTime,a.`goods_rank` AS goodsRank, a.`content`,a.`imgs` FROM t_comment a WHERE a.goods_id=#{goodsId} </select> <select id="getChildrenModues" parameterType="java.lang.L