KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > dependent > bean > Customer


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.tutorial.dependent.bean;
8
9 import javax.persistence.AttributeOverride;
10 import javax.persistence.AttributeOverrides;
11 import javax.persistence.Column;
12 import javax.persistence.Embedded;
13 import javax.persistence.Entity;
14 import javax.persistence.GeneratorType;
15 import javax.persistence.Id;
16 import javax.persistence.Table;
17
18 @Entity
19 @Table(name = "CUSTOMER")
20 public class Customer implements java.io.Serializable JavaDoc
21 {
22    private int id;
23    private Name name;
24    private String JavaDoc street;
25    private String JavaDoc city;
26    private String JavaDoc state;
27    private String JavaDoc zip;
28
29    public Customer()
30    {
31    }
32
33    public Customer(String JavaDoc first, String JavaDoc last, String JavaDoc street, String JavaDoc city, String JavaDoc state, String JavaDoc zip)
34    {
35       this.name = new Name(first, last);
36       this.street = street;
37       this.city = city;
38       this.state = state;
39       this.zip = zip;
40    }
41
42    @Id(generate = GeneratorType.AUTO)
43    public int getId()
44    {
45       return id;
46    }
47
48    public void setId(int id)
49    {
50       this.id = id;
51    }
52
53
54    @Embedded
55    @AttributeOverrides({
56    @AttributeOverride(name = "first", column = @Column(name = "FIRST_NAME")),
57    @AttributeOverride(name = "last", column = @Column(name = "LAST_NAME"))
58    })
59    public Name getName()
60    {
61       return name;
62    }
63
64    public void setName(Name name)
65    {
66       this.name = name;
67    }
68
69    @Column(name = "STREET")
70    public String JavaDoc getStreet()
71    {
72       return street;
73    }
74
75    public void setStreet(String JavaDoc street)
76    {
77       this.street = street;
78    }
79
80    @Column(name = "CITY")
81    public String JavaDoc getCity()
82    {
83       return city;
84    }
85
86    public void setCity(String JavaDoc city)
87    {
88       this.city = city;
89    }
90
91    @Column(name = "STATE")
92    public String JavaDoc getState()
93    {
94       return state;
95    }
96
97    public void setState(String JavaDoc state)
98    {
99       this.state = state;
100    }
101
102    @Column(name = "ZIP")
103    public String JavaDoc getZip()
104    {
105       return zip;
106    }
107
108    public void setZip(String JavaDoc zip)
109    {
110       this.zip = zip;
111    }
112 }
113
Popular Tags