You'll also see inverse rearing its head in
many-to-many relationships as well:
Code:
public class LeftManyStudent {
@ManyToMany
@JoinTable(name = "join_table",
joinColumns = { @JoinColumn(name = "lmstudent_id")},
inverseJoinColumns={@JoinColumn(name="rmcourse_id")})
public List<RightManyCourse> getCourses(){return courses;}
}
***

***
Code:
public class RightManyCourse {
@ManyToMany
@JoinTable(name = "join_table",
joinColumns={@JoinColumn(name="rmcourse_id")},
inverseJoinColumns={@JoinColumn(name="lmstudent_id")})
public List<LeftManyStudent> getStudents(){return students;}
}
Mapping many-to-many relationships with Hibernate and JPA Annotations Tutorial