1 22 package org.jboss.ejb3.test.entity; 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.GeneratedValue; 31 import javax.persistence.GenerationType; 32 import javax.persistence.Id; 33 import javax.persistence.JoinColumn; 34 import javax.persistence.ManyToMany; 35 import javax.persistence.ManyToOne; 36 import javax.persistence.Table; 37 import javax.persistence.TableGenerator; 38 import javax.persistence.Transient; 39 import javax.persistence.Version; 40 41 46 @TableGenerator( 47 name="default-generator", 48 table="TEST_GENERATOR_TABLE", 49 pkColumnValue= "TEST_PK", 50 allocationSize = 20 51 ) 52 @Entity 53 public class Flight implements java.io.Serializable 54 { 55 Long id; 56 String name; 57 long duration; 58 long durationInSec; 59 Integer version; 60 Company company; 61 Set <Customer> customers; 62 63 @Id 64 @GeneratedValue(strategy=GenerationType.TABLE, generator = "default-generator") 65 public Long getId() 66 { 67 return id; 68 } 69 70 public void setId(Long long1) 71 { 72 id = long1; 73 } 74 75 @Column(updatable = false, name = "flight_name", nullable = false, length = 50) 76 public String getName() 77 { 78 return name; 79 } 80 81 public void setName(String string) 82 { 83 name = string; 84 } 85 86 @Basic(fetch = FetchType.LAZY) 87 public long getDuration() 88 { 89 return duration; 90 } 91 92 public void setDuration(long l) 93 { 94 duration = l; 95 } 97 98 @Transient 99 public long getDurationInSec() 100 { 101 return durationInSec; 102 } 103 104 public void setDurationInSec(long l) 105 { 106 durationInSec = l; 107 } 108 109 @Version 110 @Column(name = "OPTLOCK") 111 public Integer getVersion() 112 { 113 return version; 114 } 115 116 public void setVersion(Integer i) 117 { 118 version = i; 119 } 120 121 @ManyToOne(cascade = {CascadeType.ALL}) 123 @JoinColumn(name = "COMP_ID") 124 public Company getCompany() 125 { 126 return company; 127 } 128 129 public void setCompany(Company company) 130 { 131 this.company = company; 132 } 133 134 @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER) 135 public Set <Customer> getCustomers() 136 { 137 return customers; 138 } 139 140 public void setCustomers(Set <Customer> customers) 141 { 142 this.customers = customers; 143 } 144 } 145 | Popular Tags |