1 22 package org.jboss.ejb3.test.composite; 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.Transient; 35 import javax.persistence.Version; 36 37 42 @Entity() 43 public class Flight implements java.io.Serializable 44 { 45 Long id; 46 String name; 47 long duration; 48 long durationInSec; 49 Integer version; 50 Set <Customer> customers; 51 52 @Id 53 public Long getId() 54 { 55 return id; 56 } 57 58 public void setId(Long long1) 59 { 60 id = long1; 61 } 62 63 @Column(updatable = false, name = "flight_name", nullable = false, length = 50) 64 public String getName() 65 { 66 return name; 67 } 68 69 public void setName(String string) 70 { 71 name = string; 72 } 73 74 @Basic(fetch = FetchType.LAZY) 75 public long getDuration() 76 { 77 return duration; 78 } 79 80 public void setDuration(long l) 81 { 82 duration = l; 83 } 85 86 @Transient 87 public long getDurationInSec() 88 { 89 return durationInSec; 90 } 91 92 public void setDurationInSec(long l) 93 { 94 durationInSec = l; 95 } 96 97 @Version 98 @Column(name = "OPTLOCK") 99 public Integer getVersion() 100 { 101 return version; 102 } 103 104 public void setVersion(Integer i) 105 { 106 version = i; 107 } 108 109 @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER) 110 @JoinTable(name = "flight_customer_table", 111 joinColumns = {@JoinColumn(name = "FLIGHT_ID")}, 112 inverseJoinColumns = {@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")}) 113 public Set <Customer> getCustomers() 114 { 115 return customers; 116 } 117 118 public void setCustomers(Set <Customer> customers) 119 { 120 this.customers = customers; 121 } 122 } 123 | Popular Tags |