[jboss-user] [JBoss Seam] - Re: help with EntityList

terryb do-not-reply at jboss.com
Wed Oct 31 02:00:26 EDT 2007


cut down version of entities involved. I guess I am not sure how to build ejb 
for my case and how to use it in restrictions and eventually how to access it in jsf


  | @Entity
  | @Table(name = "Client")
  | public class Client implements java.io.Serializable {
  | 
  |   private String id;
  |   private String username;
  |   private Set<Contact> contacts = new HashSet<Contact>(0);
  |   private Set<Applicant> applicants = new HashSet<Applicant>(0);
  | 
  |   public Client() {
  |   }
  | 
  |   .....
  | 
  |   @Id
  |   @Column(name = "ID", unique = true, nullable = false, length = 20)
  |   @NotNull
  |   @Length(max = 20)
  |   public String getId() {
  |     return this.id;
  |   }
  | 
  |   public void setId(String id) {
  |     this.id = id;
  |   }
  | 
  |   @Column(name = "Username", length = 20)
  |   @Length(max = 20)
  |   public String getUsername() {
  |     return this.username;
  |   }
  | 
  |   public void setUsername(String username) {
  |     this.username = username;
  |   }
  | 
  |   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "client")
  |   public Set<Contact> getContacts() {
  |     return this.contacts;
  |   }
  | 
  |   public void setContacts(Set<Contact> contacts) {
  |     this.contacts = contacts;
  |   }
  |   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "client")
  |   public Set<Applicant> getApplicants() {
  |     return this.applicants;
  |   }
  | 
  |   public void setApplicants(Set<Applicant> applicants) {
  |     this.applicants = applicants;
  |   }
  | 
  | }
  | 
  | @Entity
  | @Table(name = "Contact")
  | public class Contact implements java.io.Serializable {
  | 
  |   private String id;
  |   private Client client;
  |   private String surname;
  |   private Set<Address> addresses = new HashSet<Address>(0);
  | 
  |   @ManyToOne(fetch = FetchType.LAZY)
  |   @JoinColumn(name = "ClientID")
  |   public Client getClient() {
  |     return this.client;
  |   }
  | 
  |   public void setClient(Client client) {
  |     this.client = client;
  |   }
  | 
  |   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "contact")
  |   public Set<Address> getAddresses() {
  |     return this.addresses;
  |   }
  | 
  |   public void setAddresses(Set<Address> addresses) {
  |     this.addresses = addresses;
  |   }
  | }
  | 
  | @Entity
  | @Table(name = "Address")
  | public class Address implements java.io.Serializable {
  | 
  |   private String id;
  |   private Contact contact;
  | 
  |   @ManyToOne(fetch = FetchType.LAZY)
  |   @JoinColumn(name = "ContactID")
  |   public Contact getContact() {
  |     return this.contact;
  |   }
  | 
  |   public void setContact(Contact contact) {
  |     this.contact = contact;
  |   }
  | 
  | 
  | }
  | 
  | 
  | JSF
  | ...
  | <h:dataTable id="clientList" var="client" value="#{clientList.resultList}" rendered="#{not empty clientList.resultList}" border="1">
  | 
  | <h:column>
  | #{client....????}
  | </h:column>
  | ...
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100502#4100502

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100502



More information about the jboss-user mailing list