KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > annotations > Customer


1 //$Id: Customer.java,v 1.4 2005/07/15 05:12:47 epbernard Exp $
2
package org.hibernate.test.annotations;
3
4 import java.io.Serializable JavaDoc;
5 import java.util.Collection JavaDoc;
6 import java.util.SortedSet JavaDoc;
7 import javax.persistence.CascadeType;
8 import javax.persistence.Entity;
9 import javax.persistence.FetchType;
10 import javax.persistence.GeneratorType;
11 import javax.persistence.Id;
12 import javax.persistence.JoinColumn;
13 import javax.persistence.OneToMany;
14 import javax.persistence.OneToOne;
15
16 import org.hibernate.annotations.Sort;
17 import org.hibernate.annotations.SortType;
18 import org.hibernate.annotations.Cascade;
19
20 import static org.hibernate.annotations.CascadeType.*;
21
22
23 /**
24  * Company customer
25  * @author Emmanuel Bernard
26  */

27 @Entity
28 public class Customer implements Serializable JavaDoc {
29     Long JavaDoc id;
30     String JavaDoc name;
31     SortedSet JavaDoc<Ticket> tickets;
32     Collection JavaDoc discountTickets;
33     Passport passport;
34
35     public Customer() {
36     }
37
38     @Id(generate = GeneratorType.AUTO)
39     public Long JavaDoc getId() {
40         return id;
41     }
42
43     public String JavaDoc getName() {
44         return name;
45     }
46
47     public void setId(Long JavaDoc long1) {
48         id = long1;
49     }
50
51     public void setName(String JavaDoc string) {
52         name = string;
53     }
54     
55     @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
56     @JoinColumn(name="CUST_ID")
57     @Sort(type = SortType.COMPARATOR, comparator = TicketComparator.class)
58     public SortedSet JavaDoc<Ticket> getTickets() {
59         return tickets;
60     }
61     
62     public void setTickets(SortedSet JavaDoc<Ticket> tickets) {
63         this.tickets = tickets;
64     }
65
66     @OneToMany(targetEntity=org.hibernate.test.annotations.Discount.class,
67             cascade=CascadeType.ALL, mappedBy="owner")
68     @Cascade( {ALL} )
69     public Collection JavaDoc getDiscountTickets() {
70         return discountTickets;
71     }
72
73     public void setDiscountTickets(Collection JavaDoc collection) {
74         discountTickets = collection;
75     }
76     
77     @OneToOne(cascade = CascadeType.ALL)
78     public Passport getPassport() {
79         return passport;
80     }
81
82     public void setPassport(Passport passport) {
83         this.passport = passport;
84     }
85
86 }
87
88
Popular Tags