我有一个带有OneToMany注释的实体课程到CourseUser。我试图从课程中的course_name等于CourseUser中的course_name和course_usere中的user_name等于' name'来获取所有行。但在hql中我得到一个错误。我对所有关于相同错误的问题都是红色的,但我很难理解路径是如有人可以向我解释吗? 这是hql:
"from Courses inner join CourseUser on courses.course_name = CourseUser.course_name and CourseUser.user_name =:name "
课程实体:
@Entity
@Table(name = "COURSES")
public class Courses {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "course_id")
private int course_id;
@Column(name = "course_name", nullable = false)
private String courseName;
@Column(name = "course_owner", nullable = false)
private String course_owner;
@Column(name = "course_description")
private String courseDescription;
@Column(name = "course_links")
private String links;
@Column(name = "course_category")
private String category;
@Column(name = "course_state")
private String state = "draft";
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Set<CourseUser> courseUsers = new HashSet<CourseUser>(0);
和CourseUser实体:
@Entity
@Table(name = "COURSE_USERS",
uniqueConstraints = {@UniqueConstraint(columnNames = {"course_name", "user_name"})})
public class CourseUser {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ev_id")
private int course_id;
@Column(name = "course_name", nullable = false)
private String courseName;
@Column(name = "user_name", nullable = false)
private String userName;
@Column(name = "course_role")
private String courseRole;
@Column(name = "grade")
private int grade ;