Reputation: 99
I have entity class Publication. It connected with entity class Teacher as ManyToMany.
Here's part of Publication class
// create connectivity with table Teacher
public Set<Teacher> teachers;
@ManyToMany
@JoinTable(name = "Bridge2",
joinColumns = @JoinColumn(name = "PublicationId"),
inverseJoinColumns = @JoinColumn(name = "TeacherId"))
public Set<Teacher> getTeacher() {
return teachers;
}
public void setTeacher(Set<Teacher> teachers) {
this.teachers = teachers;
}
I select publication from database and pass it to JSP page. At JSP page I try to view all teachers but always get exception Property 'teachers' not found on type org.irs.entities.Publication.
Here's part of JSP file
<td> <!-- view all teachers -->
<c:forEach var="t" items="${publication.teachers}">
${t.teacherFullName}<br/>
</c:forEach>
</td>
If anyone knows the reason of this problem, I'll be gratful for help.
Upvotes: 0
Views: 1286
Reputation: 2500
It seems it's because of your getter
and setter
are teacher
rather than teachers
. Hibernate regards setter
and getters
rather than fields. Changing them to setTeacher*s* and getTeacher*s* may resolve problem.
Upvotes: 2
Reputation: 992
Try renaming your accessor methods to getTeachers
and setTeachers
(plural instead of singular).
Hibernate sees getTeacher
, so the property name is teacher
. You are trying to to access the property teachers
instead.
Upvotes: 3