Hi,
How to map a normat containment using hibernate?
e.g.
I have a Teacher class that contains an array of Subjects he teaches.
public class Teacher {
private long TeacherID;
private String Name;
private Subject[] subjectsTaught;
}
And a Subject class
public class Subject implements Serializable {
private int SubjectId;
private String Name;
private int HrsperWeek;
private long TaughtBy;
}
I have 2 tables, with Subject Table having a foreign key to Teacher.
How to map this such that when I say session.save(teacherObject), I should get the subjects saved and their foreign keys set correctly?
If I just mark the 'subjectsTaught' member of Teacher as Property with type=Subject, and a many-to-one mapping for Subject's foreign key member 'TaughtBy', it throws an error,
multiple imports : Teacher.
One mroe, How can I get help on error messages displayed by hibernate, like meaning of 'multiple imports'
|