How can I fetch a many to one relationship in a JSP page? I tried
<s:property value="group.division.name" />
but no data appeared on the JSP.
The Group
can belong to one Division
.
public class Group implements java.io.Serializable {
..
private Division division;
..
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "div_id", nullable = false)
public Division getDivision() {
return this.division;
}
public void setDivision(Division division) {
this.division = division;
}
}
And
public class Division implements java.io.Serializable {
...
private String name;
private Set<Group> groups = new HashSet<Group>(0);
@Column(name = "name", nullable = false, length = 50)
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "division")
public Set<Group> getGroups() {
return this.groups;
}
public void setGroups(Set<Group> groups) {
this.groups = groups;
}
}