1 22 package org.jboss.ejb3.test.entity; 23 24 import java.util.Set ; 25 import javax.persistence.CascadeType; 26 import javax.persistence.Entity; 27 import javax.persistence.FetchType; 28 import javax.persistence.GeneratedValue; 29 import javax.persistence.GenerationType; 30 import javax.persistence.Id; 31 import javax.persistence.JoinColumn; 32 import javax.persistence.ManyToMany; 33 import javax.persistence.OneToMany; 34 import javax.persistence.OneToOne; 35 36 41 @Entity 42 public class Customer implements java.io.Serializable 43 { 44 Long id; 45 String name; 46 Set <Ticket> tickets; 47 Set <Flight> flights; 48 Address address; 49 50 public 51 Customer() 52 { 53 } 54 55 @Id 56 @GeneratedValue(strategy= GenerationType.AUTO) 57 public 58 Long getId() 59 { 60 return id; 61 } 62 63 public 64 String getName() 65 { 66 return name; 67 } 68 69 public 70 void setId(Long long1) 71 { 72 id = long1; 73 } 74 75 public 76 void setName(String string) 77 { 78 name = string; 79 } 80 81 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="customer") 82 public Set <Ticket> getTickets() 83 { 84 return tickets; 85 } 86 87 public void setTickets(Set <Ticket> tickets) 88 { 89 this.tickets = tickets; 90 } 91 92 @OneToOne(cascade = {CascadeType.ALL}) 93 @JoinColumn(name = "ADDRESS_ID") 94 public Address getAddress() 95 { 96 return address; 97 } 98 99 public void setAddress(Address address) 100 { 101 this.address = address; 102 } 103 104 @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers") 105 public Set <Flight> getFlights() 106 { 107 return flights; 108 } 109 110 public void setFlights(Set <Flight> flights) 111 { 112 this.flights = flights; 113 } 114 115 116 130 } 131 132 | Popular Tags |