1 package org.jboss.tutorial.relationships.bean; 3 4 import javax.persistence.JoinTable; 5 import javax.persistence.Basic; 6 import javax.persistence.CascadeType; 7 import javax.persistence.Column; 8 import javax.persistence.Entity; 9 import javax.persistence.FetchType; 10 import javax.persistence.Id; 11 import javax.persistence.JoinColumn; 12 import javax.persistence.ManyToMany; 13 import javax.persistence.Table; 14 import javax.persistence.Column; 15 import javax.persistence.Transient; 16 import javax.persistence.Version; 17 import javax.persistence.Version; 18 import javax.persistence.ManyToMany; 19 import javax.persistence.CascadeType; 20 import javax.persistence.FetchType; 21 22 import java.util.Set ; 23 24 29 @Entity() 30 public class Flight implements java.io.Serializable 31 { 32 Long id; 33 String name; 34 long duration; 35 long durationInSec; 36 Integer version; 37 Set <Customer> customers; 38 39 @Id 40 public Long getId() 41 { 42 return id; 43 } 44 45 public void setId(Long long1) 46 { 47 id = long1; 48 } 49 50 @Column(updatable = false, name = "flight_name", nullable = false, length = 50) 51 public String getName() 52 { 53 return name; 54 } 55 56 public void setName(String string) 57 { 58 name = string; 59 } 60 61 @Basic(fetch = FetchType.LAZY) 62 public long getDuration() 63 { 64 return duration; 65 } 66 67 public void setDuration(long l) 68 { 69 duration = l; 70 } 72 73 @Transient 74 public long getDurationInSec() 75 { 76 return durationInSec; 77 } 78 79 public void setDurationInSec(long l) 80 { 81 durationInSec = l; 82 } 83 84 @Version 85 @Column(name = "OPTLOCK") 86 public Integer getVersion() 87 { 88 return version; 89 } 90 91 public void setVersion(Integer i) 92 { 93 version = i; 94 } 95 96 @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER) 97 @JoinTable(table = @Table(name = "flight_customer_table"), 98 joinColumns = {@JoinColumn(name = "FLIGHT_ID")}, 99 inverseJoinColumns = {@JoinColumn(name = "CUSTOMER_ID")}) 100 public Set <Customer> getCustomers() 101 { 102 return customers; 103 } 104 105 public void setCustomers(Set <Customer> customers) 106 { 107 this.customers = customers; 108 } 109 } 110 | Popular Tags |