KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > composite > Flight


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.test.composite;
23
24 import java.util.Set JavaDoc;
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.Id;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.JoinTable;
33 import javax.persistence.ManyToMany;
34 import javax.persistence.Transient;
35 import javax.persistence.Version;
36
37 /**
38  * Flight
39  *
40  * @author Emmanuel Bernard
41  */

42 @Entity()
43 public class Flight implements java.io.Serializable JavaDoc
44 {
45    Long JavaDoc id;
46    String JavaDoc name;
47    long duration;
48    long durationInSec;
49    Integer JavaDoc version;
50    Set JavaDoc<Customer> customers;
51
52    @Id
53    public Long JavaDoc getId()
54    {
55       return id;
56    }
57
58    public void setId(Long JavaDoc long1)
59    {
60       id = long1;
61    }
62
63    @Column(updatable = false, name = "flight_name", nullable = false, length = 50)
64    public String JavaDoc getName()
65    {
66       return name;
67    }
68
69    public void setName(String JavaDoc string)
70    {
71       name = string;
72    }
73
74    @Basic(fetch = FetchType.LAZY)
75    public long getDuration()
76    {
77       return duration;
78    }
79
80    public void setDuration(long l)
81    {
82       duration = l;
83       //durationInSec = duration / 1000;
84
}
85
86    @Transient
87    public long getDurationInSec()
88    {
89       return durationInSec;
90    }
91
92    public void setDurationInSec(long l)
93    {
94       durationInSec = l;
95    }
96
97    @Version
98    @Column(name = "OPTLOCK")
99    public Integer JavaDoc getVersion()
100    {
101       return version;
102    }
103
104    public void setVersion(Integer JavaDoc i)
105    {
106       version = i;
107    }
108
109    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
110    @JoinTable(name = "flight_customer_table",
111                      joinColumns = {@JoinColumn(name = "FLIGHT_ID")},
112                      inverseJoinColumns = {@JoinColumn(name = "CUSTOMER_ID"), @JoinColumn(name = "CUSTOMER_NAME")})
113    public Set JavaDoc<Customer> getCustomers()
114    {
115       return customers;
116    }
117
118    public void setCustomers(Set JavaDoc<Customer> customers)
119    {
120       this.customers = customers;
121    }
122 }
123
Popular Tags