package com.yh.manytoOne;
import java.util.HashSet;
import java.util.Set;
/*
* dept-emp 一对多
* 在一的一方添加多的一方的集合
* 实体关联映射文件配置:
* <set name="集合属性名称">
* <key>
* <column name="关联实体的主键的字段名"/>
* </key>
* <one-to-many class="关联实体的名称"/>
* </set>
*
*/
public class Dept {
private int deptNo;
private String dName;
private Set<Emp> empSet=new HashSet<Emp>();
public Set<Emp> getEmpSet() {
return empSet;
}
public void setEmpSet(Set<Emp> empSet) {
this.empSet = empSet;
}
public int getDeptNo() {
return deptNo;
}
public void setDeptNo(int deptNo) {
this.deptNo = deptNo;
}
public String getdName() {
return dName;
}
public void setdName(String dName) {
this.dName = dName;
}
}
import java.util.HashSet;
import java.util.Set;
/*
* dept-emp 一对多
* 在一的一方添加多的一方的集合
* 实体关联映射文件配置:
* <set name="集合属性名称">
* <key>
* <column name="关联实体的主键的字段名"/>
* </key>
* <one-to-many class="关联实体的名称"/>
* </set>
*
*/
public class Dept {
private int deptNo;
private String dName;
private Set<Emp> empSet=new HashSet<Emp>();
public Set<Emp> getEmpSet() {
return empSet;
}
public void setEmpSet(Set<Emp> empSet) {
this.empSet = empSet;
}
public int getDeptNo() {
return deptNo;
}
public void setDeptNo(int deptNo) {
this.deptNo = deptNo;
}
public String getdName() {
return dName;
}
public void setdName(String dName) {
this.dName = dName;
}
}