1 package org.jboss.tutorial.relationships.bean; 3 4 import javax.persistence.CascadeType; 5 import javax.persistence.Entity; 6 import javax.persistence.FetchType; 7 import javax.persistence.GeneratorType; 8 import javax.persistence.Id; 9 import javax.persistence.JoinColumn; 10 import javax.persistence.ManyToMany; 11 import javax.persistence.OneToOne; 12 import javax.persistence.JoinColumn; 13 import javax.persistence.Id; 14 import javax.persistence.ManyToMany; 15 import javax.persistence.CascadeType; 16 import javax.persistence.GeneratorType; 17 import javax.persistence.Entity; 18 import java.util.Set ; 19 20 25 @Entity 26 public class Customer implements java.io.Serializable 27 { 28 Long id; 29 String name; 30 Set <Flight> flights; 31 Address address; 32 33 public Customer() 34 { 35 } 36 37 @Id(generate = GeneratorType.IDENTITY) 38 public Long getId() 39 { 40 return id; 41 } 42 43 public String getName() 44 { 45 return name; 46 } 47 48 public void setId(Long long1) 49 { 50 id = long1; 51 } 52 53 public void setName(String string) 54 { 55 name = string; 56 } 57 58 @OneToOne(cascade = {CascadeType.ALL}) 59 @JoinColumn(name = "ADDRESS_ID") 60 public Address getAddress() 61 { 62 return address; 63 } 64 65 public void setAddress(Address address) 66 { 67 this.address = address; 68 } 69 70 @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers") 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 84 | Popular Tags |