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.JoinColumn; 30 import javax.persistence.Id; 31 import javax.persistence.OneToOne; 32 import javax.persistence.ManyToMany; 33 import javax.persistence.OneToMany; 34 import javax.persistence.OneToOne; 35 import javax.persistence.OneToMany; 36 import javax.persistence.CascadeType; 37 import javax.persistence.FetchType; 38 import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; 39 import javax.persistence.Entity; 40 import java.util.Set ; 41 42 47 @Entity 48 public class Customer implements java.io.Serializable 49 { 50 Long id; 51 String name; 52 Set <Ticket> tickets; 53 Set <Flight> flights; 54 Address address; 55 56 public 57 Customer() 58 { 59 } 60 61 @Id @GeneratedValue(strategy=GenerationType.IDENTITY) 62 public 63 Long getId() 64 { 65 return id; 66 } 67 68 public 69 String getName() 70 { 71 return name; 72 } 73 74 public 75 void setId(Long long1) 76 { 77 id = long1; 78 } 79 80 public 81 void setName(String string) 82 { 83 name = string; 84 } 85 86 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="customer") 87 public Set <Ticket> getTickets() 88 { 89 return tickets; 90 } 91 92 public void setTickets(Set <Ticket> tickets) 93 { 94 this.tickets = tickets; 95 } 96 97 @OneToOne(cascade = {CascadeType.ALL}) 98 @JoinColumn(name = "ADDRESS_ID") 99 public Address getAddress() 100 { 101 return address; 102 } 103 104 public void setAddress(Address address) 105 { 106 this.address = address; 107 } 108 109 @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers") 110 public Set <Flight> getFlights() 111 { 112 return flights; 113 } 114 115 public void setFlights(Set <Flight> flights) 116 { 117 this.flights = flights; 118 } 119 120 121 } 122 123 | Popular Tags |