1.pojo代码
private Integer categoryId;
private Integer superId;
private String name;
private Byte level;
private String categoryImageUrl;
private Integer rank;
private Boolean isEnable;
private Date addTime;
private Date updateTime;
private List<Goods_category> child_goods_category;
2.Dao代码
List<Goods_category> getCategorys();
3.mybatis.xml中的代码
<!-- 分类 -->
<resultMap type="rrg.bean.Goods_category" id="recursionGoods_categoryMap" extends="BaseResultMap">
<collection property="child_goods_category" ofType="Goods_category" column="category_id" select="findGoods_categoryByParentId"></collection>
</resultMap>
<select id="getCategorys" resultMap="recursionGoods_categoryMap">
SELECT * FROM goods_category WHERE super_id ='' or super_id is NULL ORDER BY category_id ASC
</select>
<select id="findGoods_categoryByParentId" resultMap="recursionGoods_categoryMap">
SELECT * FROM goods_category WHERE super_id = #{category_id} ORDER BY category_id ASC
</select>