title: JPA auto_increment id for generated @ManyToMany join table
body: <p>If I have a bidirectional @ManyToMany relationship between two entities (ie <code>Student</code> and <code>Course</code>), JPA generates a join table, <code>student_id_course_id</code>, with a composite primary key of <code>(student_id, course_id)</code>. That all works fine.</p>
  
  <p>But what if I had a whole heap of other tables that work off that key, for example, <code>course_assessment</code> and <code>course_result</code>, that looked like this:</p>
  
  <pre><code>course_assessment
    student_id
    course_id
    assessment_item_description
    grade
  
  course_result
    student_id
    course_id
    overall_grade
  </code></pre>
  
  <p>I don't want to proliferate the composite key <code>(student_id, course_id)</code> through these tables. I'd prefer for <code>student_id_course_id</code> to have a single auto_increment id and then to use that in the <code>course_assessment</code> and <code>course_result</code> tables.</p>
  
  <p>This seems like it would be a fairly common scenario in JPA, but I haven't been able to find out how to do it. How do other people typically approach this?</p>