I created those tables myself using the SQL statements first before I create the entity classes.
I guess the composite primary key is (student, semester , course) instead of (student, semester) or (student, course).
If I use two columns as the composite key, this key may not be unique. The enrollments join table will be like this for example:
Student Semester Course
----------------------------------
1 Spring JPA
1 Spring
EJB
1 Winter
Servlet
1 Winter
JSF
1 Fall JSF
1 Summer JSF
I cannot pick (student, semester) or (student, course) as the composite key because of these reasons:
- a student may enroll in more than one course in one semester or
- a student may repeat the same course in different semesters.