Hello again Mr. Tsang. I'm trying to set up my entities' relationships and I've ran into an issue. I don't think I've understood the mapping quite well, any clarification would be really helpful.
Let's take the Course - Lectures relationship. It's a unidirectional one, meaning that the Course is the owner of the relationship. So, the Course entity must have a
List<Lectures> field and a
@OneToMany(mappedBy="course").
The Lectures entity is a
@ManyToOne relationship and the
JoinTable is the
CourseLectures one. Also, it should have a
Courses course field based on
this.
My entities are following:
Judging by the link I've given you it's the exact same case, only the
Courses=Groups and
Lectures=Users.
In my
CoursesFacade class, I'm trying to return the
Lectures that correspond to a given Course name. When I do
select lec from Lectures lec where lec.course.title = :cname it crashes. Should this query be in the
LecturesFacade and not in the
CoursesFacade?
I thought I had understood the mapping after reading the specific chapter on "Beginning JavaEE7" but I guess I hadn't. Care to enlighten me?