I asked a question earlier, but think it wasn\'t clear enough i will elaborate further with the code.
I have a Teacher entity and Department entity
Many Teachers
I removed the @oneToOne relationship between Teacher and Department and created a new entity called DepartmentHeads, everything now works fine.
Here is the Results.
@Entity
public class Teacher extends Model {
@Required
public String surname;
@Required
public String othernames;
...
@ManyToOne(cascade=CascadeType.ALL)
public Department dept = new Department();
...
}
@Entity
public class Department extends Model {
@Required
public String deptName;
@OneToMany(mappedBy="dept")
public List teachers = new ArrayList();
...
}
@Entity
public class DepartmentHead extends Model{
@OneToOne
public Teacher teacher = new Teacher();
@OneToOne
public Department dept = new Department();
}
Everything now works fine.