1 22 package org.jboss.ejb3.test.manytomany; 23 24 import javax.persistence.CascadeType; 25 import javax.persistence.Entity; 26 import javax.persistence.FetchType; 27 import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; 28 import javax.persistence.Id; 29 import javax.persistence.OneToMany; 30 import javax.persistence.OneToMany; 31 import java.util.Set ; 32 33 34 39 @Entity() 40 public class Company implements java.io.Serializable 41 { 42 private Integer id; 43 private String name; 44 private Set <Flight> flights; 45 46 @Id @GeneratedValue(strategy=GenerationType.IDENTITY) 47 public Integer getId() 48 { 49 return id; 50 } 51 52 public String getName() 53 { 54 return name; 55 } 56 57 58 public void setId(Integer integer) 59 { 60 id = integer; 61 } 62 63 64 public void setName(String string) 65 { 66 name = string; 67 } 68 69 70 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="company") 71 public Set <Flight> getFlights() 72 { 73 return flights; 74 } 75 76 public void setFlights(Set <Flight> flights) 77 { 78 this.flights = flights; 79 } 80 81 82 } 83 | Popular Tags |