1 22 package org.jboss.ejb3.test.manytomany; 23 24 import java.util.Set ; 25 import javax.persistence.Basic; 26 import javax.persistence.CascadeType; 27 import javax.persistence.Column; 28 import javax.persistence.Entity; 29 import javax.persistence.FetchType; 30 import javax.persistence.Id; 31 import javax.persistence.JoinColumn; 32 import javax.persistence.JoinTable; 33 import javax.persistence.ManyToMany; 34 import javax.persistence.ManyToOne; 35 import javax.persistence.Transient; 36 import javax.persistence.Version; 37 38 43 @Entity() 44 public class Flight implements java.io.Serializable 45 { 46 Long id; 47 String name; 48 long duration; 49 long durationInSec; 50 Integer version; 51 Company company; 52 Set <Customer> customers; 53 54 @Id 55 public Long getId() 56 { 57 return id; 58 } 59 60 public void setId(Long long1) 61 { 62 id = long1; 63 } 64 65 @Column(updatable = false, name = "flight_name", nullable = false, length = 50) 66 public String getName() 67 { 68 return name; 69 } 70 71 public void setName(String string) 72 { 73 name = string; 74 } 75 76 @Basic(fetch = FetchType.LAZY) 77 public long getDuration() 78 { 79 return duration; 80 } 81 82 public void setDuration(long l) 83 { 84 duration = l; 85 } 87 88 @Transient 89 public long getDurationInSec() 90 { 91 return durationInSec; 92 } 93 94 public void setDurationInSec(long l) 95 { 96 durationInSec = l; 97 } 98 99 @Version 100 @Column(name = "OPTLOCK") 101 public Integer getVersion() 102 { 103 return version; 104 } 105 106 public void setVersion(Integer i) 107 { 108 version = i; 109 } 110 111 @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) 112 @JoinColumn(name = "COMP_ID") 113 public Company getCompany() 114 { 115 return company; 116 } 117 118 public void setCompany(Company company) 119 { 120 this.company = company; 121 } 122 123 @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER) 124 @JoinTable(name = "flight_customer_table", 125 joinColumns = {@JoinColumn(name = "FLIGHT_ID")}, 126 inverseJoinColumns = {@JoinColumn(name = "CUSTOMER_ID")}) 127 public Set <Customer> getCustomers() 128 { 129 return customers; 130 } 131 132 public void setCustomers(Set <Customer> customers) 133 { 134 this.customers = customers; 135 } 136 } 137 | Popular Tags |