ejb 3.0 - JPA and EJB - OneToMany problem -
I try to create a simple Java EE application using JPA + EJB3 and Streps. This is a little address book. I am using 2 JPA entities, individuals and email. Every person can have more emails, but each email can be of one person only. My organizations look like this (with default settings and gestures):
person.java:
@Entity public class applies the person serialzbub {@Id @GeneratedValue (Strategy = GenerationType .AUTO) Personal Long ID; The name of the private string; @OneToMany (Cascade = CascadeType.rmov, mapped = "person") private collection & lt; Email & gt; E-mail; ...}
email.Java:
@Entity public class email tool serializable {Private Static Finals long serialvarsian UID = 1 L; @ Id @ Generated Values (strategy = generation type.eeto) Private long id; Private string notes; Private string address; @ManyToOne personal person; ...}
But when I try to show everyone's list and all their emails, I can not get to show the email. In this way I am trying to print them:
& lt; C: forEach items = "$ {actionBean.people}" var = "person" & gt; & Lt; TR & gt; & Lt; Td> & Lt; C: out value = "$ {person.name}" /> gt; & Lt; / Td> & Lt; TD & gt; & Lt; C: forEach item = "$ {person.email}" var = "email" & gt; & Lt; C: out value = "$ {email.address}" /> & Lt; C: out value = "$ {email.note}" /> & Lt; / C: foreach & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / C: foreach & gt;
Any ideas, how to solve it?
Is your person
class in a getEmail ()
method or getEmails ()
method? Looking at the variable name of Email
I was given a Person.getEmails ()
attribute, but your JSTL getEmail ()
looking for Has been doing .
If this is not a problem, then I believe that you may need to add a @one column
annotation to your email
category , And add a column Email table that refers back to the person ID. In this way I have done all of my many tutorial annotations. I can find many proofs for an example.
Comments
Post a Comment