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