博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MyBatis自关联查询映射文件
阅读量:7031 次
发布时间:2019-06-28

本文共 1232 字,大约阅读时间需要 4 分钟。

hot3.png

1.pojo类

public class Category implements Serializable{		private String cid;   //分类主键	private String cname;   //分类名	private Category parent;  //父分类,是根据pid的自连接对象,一个二级分类只有一个一级分类	private String desc;   //描述	private List
children; //子分类,一个一级分类可能有多个二级分类,而二级分类无子分类 //setter and getter method...}

2.dao接口

public interface CategoryDao {			public Category load(String cid) throws SQLException;		public List
findByParent(String pid) throws SQLException; public List
findParent() throws SQLException; public void add(Category category) throws SQLException; public void edit(Category category) throws SQLException; public int findChildrenByParent(String pid) throws SQLException; public void delete(String cid) throws SQLException;}

3.Mapper映射文件(切记实体类里的toString方法里边去掉类型为List的属性,要不然打印时会出现死循环的)。

 

转载于:https://my.oschina.net/liddhome/blog/801883

你可能感兴趣的文章
jquery form 插件 分类: JavaScript ...
查看>>
php二维数组访问
查看>>
用Shell实现俄罗斯方块代码(Tetris.sh)
查看>>
[zz]Ubuntu Hadoop HDFS 配置
查看>>
上市后Avaya锣鼓全开,加速战略布局规划
查看>>
日调度5万亿次,腾讯云发布企业级微服务中间件TSF
查看>>
海外侨胞建言四川对外开放:加强内陆省份竞争力成关键
查看>>
2019款奥迪Q7上市 配置增加/69.98万元起售
查看>>
策划求婚、陪挑婚纱,新郎不是我,仍感谢你来过|在百度遇见你
查看>>
从零单排学Redis【铂金一】
查看>>
如何处理Express异常
查看>>
Cycle.js 状态管理模型
查看>>
[译]Effective Kotlin系列之考虑使用原始类型的数组优化性能(五)
查看>>
为什么我从 Google 辞职而为自己工作
查看>>
技术问答集锦(四)
查看>>
针对虚拟机搭建centos7不能上网问题处理方法
查看>>
React 源码分析
查看>>
JavaScript 算法之复杂度分析
查看>>
第六章——函数(inout参数与变异方法)
查看>>
掘金翻译计划月报 — 2018 年 2 月
查看>>