KickJava   Java API By Example, From Geeks To Geeks.

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


1 //$Id: Flight.java,v 1.4.2.5 2005/06/24 05:26:25 bill Exp $
2
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 JavaDoc;
25
26 @Entity()
27 public class Flight implements java.io.Serializable JavaDoc
28 {
29    Long JavaDoc id;
30    String JavaDoc name;
31    long duration;
32    long durationInSec;
33    Integer JavaDoc version;
34    Set JavaDoc<Customer> customers;
35
36    @Id
37    public Long JavaDoc getId()
38    {
39       return id;
40    }
41
42    public void setId(Long JavaDoc long1)
43    {
44       id = long1;
45    }
46
47    @Column(updatable = false, name = "flight_name", nullable = false, length = 50)
48    public String JavaDoc getName()
49    {
50       return name;
51    }
52
53    public void setName(String JavaDoc 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       //durationInSec = duration / 1000;
68
}
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 JavaDoc getVersion()
84    {
85       return version;
86    }
87
88    public void setVersion(Integer JavaDoc 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 JavaDoc<Customer> getCustomers()
98    {
99       return customers;
100    }
101
102    public void setCustomers(Set JavaDoc<Customer> customers)
103    {
104       this.customers = customers;
105    }
106 }
107
Popular Tags