KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > entity > 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.entity;
23
24 import java.util.Set JavaDoc;
25 import javax.persistence.CascadeType;
26 import javax.persistence.Entity;
27 import javax.persistence.FetchType;
28 import javax.persistence.GeneratedValue;
29 import javax.persistence.GenerationType;
30 import javax.persistence.Id;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.ManyToMany;
33 import javax.persistence.OneToMany;
34 import javax.persistence.OneToOne;
35
36 /**
37  * Company customer
38  *
39  * @author Emmanuel Bernard
40  */

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

130 }
131
132
Popular Tags