KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > manytomany > Customer


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.manytomany;
23
24 import javax.persistence.CascadeType;
25 import javax.persistence.Entity;
26 import javax.persistence.FetchType;
27 import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.Id;
31 import javax.persistence.OneToOne;
32 import javax.persistence.ManyToMany;
33 import javax.persistence.OneToMany;
34 import javax.persistence.OneToOne;
35 import javax.persistence.OneToMany;
36 import javax.persistence.CascadeType;
37 import javax.persistence.FetchType;
38 import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;
39 import javax.persistence.Entity;
40 import java.util.Set JavaDoc;
41
42 /**
43  * Company customer
44  *
45  * @author Emmanuel Bernard
46  */

47 @Entity
48 public class Customer implements java.io.Serializable JavaDoc
49 {
50    Long JavaDoc id;
51    String JavaDoc name;
52    Set JavaDoc<Ticket> tickets;
53    Set JavaDoc<Flight> flights;
54    Address address;
55
56    public
57    Customer()
58    {
59    }
60
61    @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
62    public
63    Long JavaDoc getId()
64    {
65       return id;
66    }
67
68    public
69    String JavaDoc getName()
70    {
71       return name;
72    }
73
74    public
75    void setId(Long JavaDoc long1)
76    {
77       id = long1;
78    }
79
80    public
81    void setName(String JavaDoc string)
82    {
83       name = string;
84    }
85
86    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="customer")
87    public Set JavaDoc<Ticket> getTickets()
88    {
89       return tickets;
90    }
91
92    public void setTickets(Set JavaDoc<Ticket> tickets)
93    {
94       this.tickets = tickets;
95    }
96
97    @OneToOne(cascade = {CascadeType.ALL})
98    @JoinColumn(name = "ADDRESS_ID")
99    public Address getAddress()
100    {
101       return address;
102    }
103
104    public void setAddress(Address address)
105    {
106       this.address = address;
107    }
108
109    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers")
110    public Set JavaDoc<Flight> getFlights()
111    {
112       return flights;
113    }
114
115    public void setFlights(Set JavaDoc<Flight> flights)
116    {
117       this.flights = flights;
118    }
119
120
121 }
122
123
Popular Tags