KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > relationships > bean > Flight


1 //$Id: Flight.java,v 1.4.2.4 2005/06/24 05:26:34 bill Exp $
2
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 JavaDoc;
23
24 /**
25  * Flight
26  *
27  * @author Emmanuel Bernard
28  */

29 @Entity()
30 public class Flight implements java.io.Serializable JavaDoc
31 {
32    Long JavaDoc id;
33    String JavaDoc name;
34    long duration;
35    long durationInSec;
36    Integer JavaDoc version;
37    Set JavaDoc<Customer> customers;
38
39    @Id
40    public Long JavaDoc getId()
41    {
42       return id;
43    }
44
45    public void setId(Long JavaDoc long1)
46    {
47       id = long1;
48    }
49
50    @Column(updatable = false, name = "flight_name", nullable = false, length = 50)
51    public String JavaDoc getName()
52    {
53       return name;
54    }
55
56    public void setName(String JavaDoc 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       //durationInSec = duration / 1000;
71
}
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 JavaDoc getVersion()
87    {
88       return version;
89    }
90
91    public void setVersion(Integer JavaDoc 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 JavaDoc<Customer> getCustomers()
101    {
102       return customers;
103    }
104
105    public void setCustomers(Set JavaDoc<Customer> customers)
106    {
107       this.customers = customers;
108    }
109 }
110
Popular Tags