我有两个Entity类,它们拥有多对多的单向关联。这是我的完整代码。如果我想获取与英语相同的课程的学生列表,将会有什么疑问?我在课程实体中没有学生列表的getter setter因为我使用单向多对多关系。请帮帮我。
@Entity
@Table(name = "course")
public class Courses {
@Id
@Column(name = "sid")
@GeneratedValue(generator = "uuid")
private String id;
//other getters setters
}
@Entity
@Table(name = "student")
public class Student {
@Id
@Column(name = "sid")
@GeneratedValue(generator = "uuid")
private String id;
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "stu_cou", joinColumns = {@JoinColumn(name = "sid", nullable = false)}, inverseJoinColumns = { @JoinColumn(name = "cid", nullable = true) })
private List<Courses> courses;
}