我有以下内容:
***Homework.class***
id;
name;
@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.MERGE,
CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.REMOVE })
@JoinColumn(name = "lesson_id", referencedColumnName = "id", nullable = false)
Lesson lesson;
@ManyToMany(mappedBy = "studentHomeworks", fetch = FetchType.LAZY)
@Cascade(org.hibernate.annotations.CascadeType.ALL)
private Set<User> homeworkStudents;
***Lesson.class***
id;
etc;
@OneToMany(mappedBy = "lesson", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<Homework> lessonHomeworks;
@ManyToMany(mappedBy = "studentLessons", fetch = FetchType.LAZY)
@Cascade(org.hibernate.annotations.CascadeType.ALL)
private Set<User> lessonStudents;
***User.class***
id;
etc.;
@ManyToMany(fetch = FetchType.LAZY, cascade = { CascadeType.MERGE,
CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.REMOVE })
@JoinTable(name = "oys_lesson_student", uniqueConstraints = @UniqueConstraint(name = "uq_student_lesson", columnNames = {
"student_id", "lesson_id" }), joinColumns = { @JoinColumn(name = "student_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "lesson_id", referencedColumnName = "id") })
private Set<Lesson> studentLessons;
@ManyToMany(fetch = FetchType.LAZY, cascade = { CascadeType.MERGE,
CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.REMOVE })
@JoinTable(name = "oys_student_homework", uniqueConstraints = @UniqueConstraint(name = "uq_student_homework", columnNames = {
"student_id", "homework_id" }), joinColumns = { @JoinColumn(name = "student_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "homework_id", referencedColumnName = "id") })
private Set<Homework> studentHomeworks;
我尝试过这样的事情:
query = "select h from Homework h where h.stop_time > :now and h.lesson in elements(:lessons)"
没有在元素关键字中设置参数功能。所以我该怎么做?我想为已注册课程的用户提供作业。我从outside.how输入已注册的课程以检查是否有对象(课程)来自家庭作业的对象)存在于从外部输入的集合(用户注册的课程)中?