If you want to have a jointable between 3 then I think you will need to create a 4th entity that maps to the jointable that has One-To-Many joins to the other 3 tables.
However you may want to look over your schema as I think you will end up with lots of duplicate data in the join table which will make it difficult if say 2 teachers were to swap classes.
I love this place!
posted 8 years ago
Thanks for your reply sean.
My question now is how can I improve my schema so that there is not duplicated data in the join table?
And how can i make OneToMany joins to the other 3 tables?
Subjects can be a domain table. You can add in another entity called a course. Students can enroll for many courses. Now lets say you have Course 1780 and 1781 that are both Physics courses but they are being taught by different teachers. A student can anytime register to anyone of the courses.
Use the @JoinColumn annotatio to join to other tables.