anar wrote:
I think both the methods don't need the second line...
-- supervisor class --
public void addStudent(Student student)
{
this.getStudents().add(student);
//student.setSupervisor(this);
}
-- student class --
public void setSupervisor(Faculty faculty)
{
this.supervisor = faculty;
//faculty.getStudents().add(this);
}
Doesn't this mean that when a student is added to a supervisors set of students with the supervisor.add(student) method, the student object won't then have it's suprvisor set.
I realise that this is the natural functionality of the Java language, I just thought there might be a way for hibernate to update both sides of the relation(i.e some form of managed persistence).
From all the examples and the caveat emptor example, it seems like the done thing is to have the relationship always updated in one direction and only put the scafolding code in that class.
cheers