生成实体类 和 cfg.xml配置
cfg.xml 参照一对多映射
实体类如下:
Project 类
package com.ddwei.entity;import java.util.HashSet;
import java.util.Set;/**
* 创建项目实体类
*
* add by author ddwei
*
* 2018/07/30
*
*/
public class Project { private int proid; private String proname; private Set<Employee2> employees = new HashSet<Employee2>(); public int getProid() {
return this.proid;
} public void setProid(int proid) {
this.proid = proid;
} public String getProname() {
return this.proname;
} public void setProname(String proname) {
this.proname = proname;
} public Set<Employee2> getEmployees() {
return employees;
} public void setEmployees(Set<Employee2> employees) {
this.employees = employees;
} public Project() {
super();
// TODO Auto-generated constructor stub
} public Project(int proid, String proname, Set<Employee2> employees) {
super();
this.proid = proid;
this.proname = proname;
this.employees = employees;
}}
Employee2类
package com.ddwei.entity;import java.util.HashSet;
import java.util.Set;/**
* 创建雇员实体类
*
* add by author ddwei
*
* 2018/07/30
*/
public class Employee2{ private int empid; private String empname; private Set<Project> projects = new HashSet<Project>(); public Employee2() {
} public int getEmpid() {
return this.empid;
} public void setEmpid(int empid) {
this.empid = empid;
} public String getEmpname() {
return this.empname;
} public void setEmpname(String empname) {
this.empname = empname;
}}