mybatis-一对一/一对多(自关联)配置文件
2018-01-19 18:33
357 查看
实体类:
映射文件:
public class Department implements Serializable { private Integer id; private String name; private Set<Department> childDept; private Department parentDept; public Department getParentDept() { return parentDept; } public void setParentDept(Department parentDept) { this.parentDept = parentDept; } public Set<Department> getChildDept() { return childDept; } public void setChildDept(Set<Department> childDept) { this.childDept = childDept; }
public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; }
映射文件:
<resultMap id="BaseResultMap" type="com.xxx.Department" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="name" property="name" jdbcType="VARCHAR" /> <association property="parentDept" column="parent_id" select="selectParent" javaType="com.ininwork.inin.po.rights.Department"></association> <collection property="childDept" ofType="com.xxx.Department" select="selectChildren" column="id"></collection> </resultMap>
相关文章推荐
- eclipses利用Mybatis关联Mysql自动生成JavaBean和mybatis配置文件
- Mybatis配置文件双向关联出现的问题
- mybatis03(配置文件实现一对一动态sql 的增删改查)
- MyBatis配置一对一关联查询的两种方式及其双向获取时注意问题
- MyBatis Spring整合配置映射接口类与映射xml文件
- 文档转载,可以参考。SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
- mybatis 引入外部属性文件 别名配置 映射文件配置
- Spring、Spring MVC、MyBatis整合文件配置详解
- Mybatis_review之配置文件中的typeAliases节点内容说明
- Mybatis学习--XML配置文件详解
- Mybatis系列(二):优化MyBatis配置文件中的配置和解决字段名与实体类属性名不相同的冲突
- SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
- mybatis中config配置文件
- java ee SSM框架连接数据库四个配置文件之二: mybatis-config.xml文件配置
- Mybatis学习总结(三).Mybatis全局配置文件
- mybatis-Config.xml全局配置文件解析
- 搭建一个mybatis,出现配置文件错误
- Mybatis的配置文件和映射文件详解
- MyBatis:Mapper配置文件的异常
- Mybatis基本配置、日志文件(sql语句)打印