我一直在寻找无济于事的解决方案。我的问题是我有两个实体“员工”和“部门”许多员工属于一个部门,一个部门由一名员工领导。任何时候都会遇到错误,同时介绍@OneToOne 和@OneToMany。这是代码
public class Department {
@Required
public String deptName;
@OneToMany(mappedBy="dept")
public List<Employee> employees = new ArrayList<Employee>();
@OneToOne
public Employee deptHead = new Employee();
.....
}
public class Employee{
@Required
public String surname;
@Required
public String othernames;
@OneToOne(mappedBy="depthead")
public Department headedBy = new Department();
@ManyToOne
public Department dept = new Department();
...
}
是否可以同时拥有注释和工作?