Hello, I try to build simple Java EE application that uses JPA + EJB3 and Stripes. It's a little address book. I'm using 2 JPA entities, Person and Email. Every person can have more emails, but each email can only belong to one person. My entities looks like this (with default setters and getters):
Person.java:
@Entity
public class Person implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
@OneToMany(cascade = CascadeType.REMOVE, mappedBy = "person")
private Collection<Email> emails; ... }
Email.java:
@Entity
public class Email implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String note;
private String address;
@ManyToOne
private Person person; ... }
But when I try to show the list of every person and all their emails, I can't get emails to show. This is how I'm trying to print them:
<c:forEach items="${actionBean.people}" var="person">
<tr>
<td><c:out value="${person.name}"/></td>
<td>
<c:forEach items="${person.email}" var="email">
<c:out value="${email.address}"/><c:out value="${email.note}"/>
</c:forEach>
</td>
</tr>
</c:forEach>
Any idea, how to solve this?