[jboss-user] [JBoss Seam] - Using OneToMany with SEAM and JSF
rgbg5
do-not-reply at jboss.com
Tue Jan 29 04:38:55 EST 2008
Hello,
i am totally new to SEAM and JSF, so i hope you dont mind if this is a stupid question or posted to the wrong forum. I just couldnt find a example for this.
I have a Entity class called Contacts which looks like this
|
| package gfm.entity;
|
| import java.io.Serializable;
| import java.util.ArrayList;
| import java.util.Date;
| import java.util.List;
| import javax.persistence.Entity;
| import javax.persistence.GeneratedValue;
| import javax.persistence.Id;
| import javax.persistence.JoinColumn;
| import javax.persistence.Lob;
| import javax.persistence.Temporal;
| import javax.persistence.TemporalType;
| import org.hibernate.annotations.CascadeType;
| import org.jboss.seam.annotations.Name;
| @Entity
| @Name("contact")
| public class Contact implements Serializable {
| private static final long serialVersionUID = 1L;
|
| @Id
| @org.hibernate.annotations.GenericGenerator(name="uuid_gen", strategy="uuid")
| @GeneratedValue(generator="uuid_gen")
| private String puid;
|
| private String title;
| private String firstName;
| private String middleName;
| private String lastName;
|
| private String company;
| private String department;
|
| @Temporal(TemporalType.DATE)
| private Date birthday;
|
| @Lob
| private String notes;
|
| @org.hibernate.annotations.CollectionOfElements
| @org.hibernate.annotations.IndexColumn(name="idx")
| @org.hibernate.annotations.Cascade(CascadeType.DELETE_ORPHAN)
| @JoinColumn(name="contact_puid")
| private List<StreetAddress> streetAddresses = new ArrayList<StreetAddress>();
|
| @org.hibernate.annotations.CollectionOfElements
| @org.hibernate.annotations.IndexColumn(name="idx")
| @org.hibernate.annotations.Cascade(CascadeType.DELETE_ORPHAN)
| @JoinColumn(name="contact_puid")
| private List<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
|
| @org.hibernate.annotations.CollectionOfElements
| @org.hibernate.annotations.IndexColumn(name="idx")
| @org.hibernate.annotations.Cascade(CascadeType.DELETE_ORPHAN)
| @JoinColumn(name="contact_puid")
| private List<CommNumber> commNumbers = new ArrayList<CommNumber>();
|
| // Getter and setter .....
|
| }
|
Each contact could have an unlimited number of addresses, emailaddresses and phone and faxnumbers.
The question is, how do i reference a single streetaddress from within a JSF Page ? and how do i add new streetadresses to contact ? I hope i explained that right.
An example or code snippet would be great.
Thank you very much,
Stefan
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4124311#4124311
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4124311
More information about the jboss-user
mailing list