0

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.