1 package org.hibernate.test.annotations; 3 4 import java.io.Serializable ; 5 import java.util.Date ; 6 import javax.persistence.Basic; 7 import javax.persistence.CascadeType; 8 import javax.persistence.Column; 9 import javax.persistence.Entity; 10 import javax.persistence.FetchType; 11 import javax.persistence.Id; 12 import javax.persistence.Inheritance; 13 import javax.persistence.InheritanceType; 14 import javax.persistence.JoinColumn; 15 import javax.persistence.ManyToOne; 16 import javax.persistence.TemporalType; 17 import javax.persistence.Transient; 18 import javax.persistence.Version; 19 20 import org.hibernate.annotations.Formula; 21 22 27 @Entity() 28 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) 29 public class Flight implements Serializable { 30 Long id; 31 String name; 32 Long duration; 33 long durationInSec; 34 long maxAltitudeInMilimeter; 35 long maxAltitude; 36 Integer version; 37 Company company; 38 String triggeredData; 39 long factor; 40 Date departureDate; 41 42 @Id 43 public Long getId() { 44 return id; 45 } 46 47 public void setId(Long long1) { 48 id = long1; 49 } 50 51 @Column(name = "flight_name", nullable = false, updatable = false, length=50) 52 public String getName() { 53 return name; 54 } 55 56 public void setName(String string) { 57 name = string; 58 } 59 60 @Basic(fetch = FetchType.LAZY, optional = false) 61 public Long getDuration() { 62 return duration; 63 } 64 65 @Basic(temporalType = TemporalType.DATE) 66 public Date getDepartureDate() { 67 return departureDate; 68 } 69 70 public void setDepartureDate(Date departureDate) { 71 this.departureDate = departureDate; 72 } 73 74 75 public void setDuration(Long l) { 76 duration = l; 77 } 79 80 @Transient 81 public long getDurationInSec() { 82 return durationInSec; 83 } 84 85 public void setDurationInSec(long l) { 86 durationInSec = l; 87 } 88 89 @Version 90 @Column(name="OPTLOCK") 91 public Integer getVersion() { 92 return version; 93 } 94 95 public void setVersion(Integer i) { 96 version = i; 97 } 98 99 @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} ) 100 @JoinColumn(name="COMP_ID") 101 public Company getCompany() { 102 return company; 103 } 104 105 public void setCompany(Company company) { 106 this.company = company; 107 } 108 109 @Column(insertable=false, updatable=false) 110 public String getTriggeredData() { 111 return triggeredData; 112 } 113 114 public void setTriggeredData(String string) { 115 triggeredData = string; 116 } 117 118 public void getIsNotAGetter() { 119 } 121 122 public long getFactor(boolean x10) { 123 return factor * (1 + ( x10==true ? 9 : 0 ) ); 125 } 126 127 public void setFactor(long factor) { 128 this.factor = factor; 129 } 130 131 public long getMaxAltitude() { 132 return maxAltitude; 133 } 134 135 public void setMaxAltitude(long maxAltitude) { 136 this.maxAltitude = maxAltitude; 137 } 138 139 @Formula("maxAltitude * 1000") 140 public long getMaxAltitudeInMilimeter() { 141 return maxAltitudeInMilimeter; 142 } 143 144 public void setMaxAltitudeInMilimeter(long maxAltitudeInMilimeter) { 145 this.maxAltitudeInMilimeter = maxAltitudeInMilimeter; 146 } 147 148 } | Popular Tags |