[英]How to fetch list using Criteria Many to Many unidirectional association in hibernate?
I have two Entity classes which possess many to many uni directional association.Here is my full code. 我有两个Entity类,它们具有多对多的单向关联。这是我的完整代码。 What would be query if I want to fetch list of students which have same course like English ? 如果我想获取与英语课程相同的学生名单,该怎么办? I have no getter setter of list of student in Courses Entity because I am using unidirectional many to many relationship . 我没有课程实体中学生列表的设置程序,因为我使用的是单向多对多关系。 Please help me. 请帮我。
@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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.