您的位置:首页 > 其它

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: