我有一个有很多关系的课程。
Student class {
@ManyToMany(fetch = FetchType.EAGER)
private List<Route> routeList;
@ManyToOne
@JoinColumn(name = "idStreet", nullable = false)
private Street idStreet;
}
Route class {
@ManyToMany(mappedBy = "routeList")
private List<Student> studentList;
@ManyToMany(fetch = FetchType.EAGER)
private List<Street> streetList;
}
Street class {
private long idStreet;
}
我需要使用HQL或函数接收与学生具有相同位置的所有路线。 用sql不起作用。
答案 0 :(得分:1)
解决:
Query query = entityManager.createQuery("from Route where :code in
elements(streetList)");
query.setParameter("codigo", idStreet);