KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xpetstore > domain > customer > ejb > Customer


1 package xpetstore.domain.customer.ejb;
2
3 import javax.ejb.CreateException JavaDoc;
4
5 import javax.persistence.CascadeType;
6 import javax.persistence.Column;
7 import javax.persistence.Entity;
8 import javax.persistence.Id;
9 import javax.persistence.JoinColumn;
10 import javax.persistence.ManyToOne;
11 import javax.persistence.Table;
12
13 import xpetstore.domain.signon.ejb.Account;
14
15 /**
16  *
17  * @ ejb.bean
18  * name="Customer"
19  * type="CMP"
20  * view-type="local"
21  * primkey-field="userId"
22  * schema="Customer"
23  * cmp-version="${ejb.cmp.version}"
24  * @ ejb.value-object
25  * name="Customer"
26  * match="*"
27  * @ ejb.transaction
28  * type="Required"
29  * @ ejb.persistence
30  * table-name="T_CUSTOMER"
31  * @ ejb.finder
32  * signature="Customer findByEmail(java.lang.String email)"
33  * query="SELECT OBJECT(c) FROM Customer AS c WHERE c.email = ?1"
34  *
35  * @ jboss.persistence
36  * create-table="${jboss.create.table}"
37  * remove-table="${jboss.remove.table}"
38  */

39 @Entity(name="Customer")
40 @Table(name="T_CUSTOMER")
41 public class Customer
42 {
43    private String JavaDoc userId;
44    private String JavaDoc firstname;
45    private String JavaDoc lastname;
46    private String JavaDoc email;
47    private String JavaDoc telephone;
48    private String JavaDoc localeId;
49    private String JavaDoc street1;
50    private String JavaDoc street2;
51    private String JavaDoc city;
52    private String JavaDoc state;
53    private String JavaDoc zipcode;
54    private String JavaDoc country;
55    private String JavaDoc creditCardNumber;
56    private String JavaDoc creditCardExpiryDate;
57    private String JavaDoc creditCardType;
58    private Account account;
59    
60    public Customer()
61    {
62       
63    }
64    
65    public Customer( Account account )
66    {
67       setUserId( account.getUserId( ) );
68    }
69    
70    public Customer(String JavaDoc userId, String JavaDoc firstname, String JavaDoc lastname, String JavaDoc email, String JavaDoc telephone, String JavaDoc localeId, String JavaDoc street1, String JavaDoc street2, String JavaDoc city, String JavaDoc state, String JavaDoc zipcode, String JavaDoc country, String JavaDoc creditCardNumber, String JavaDoc creditCardType, String JavaDoc creditCardExpiryDate)
71    {
72       this.userId = userId;
73       this.firstname = firstname;
74       this.lastname = lastname;
75       this.email = email;
76       this.telephone = telephone;
77       this.localeId = localeId;
78       this.street1 = street1;
79       this.street2 = street2;
80       this.city = city;
81       this.state = state;
82       this.zipcode = zipcode;
83       this.country = country;
84       this.creditCardNumber = creditCardNumber;
85       this.creditCardExpiryDate = creditCardExpiryDate;
86       this.creditCardType = creditCardType;
87    }
88     /**
89      * @ ejb.pk-field
90      * @ ejb.persistence
91      * column-name="userId"
92      * jdbc-type="VARCHAR"
93      * sql-type="varchar(10)"
94      * @ ejb.interface-method
95      * @ ejb.transaction
96      * type="Supports"
97      */

98    @Id
99    @Column(name="userId", length=10)
100     public String JavaDoc getUserId( )
101     {
102        return userId;
103     }
104
105     public void setUserId( String JavaDoc userId )
106     {
107        this.userId = userId;
108     }
109
110     /**
111      * @ ejb.persistence
112      * column-name="firstname"
113      * jdbc-type="VARCHAR"
114      * sql-type="varchar(50)"
115      */

116     @Column(name="firstname", length=50)
117     public String JavaDoc getFirstname( )
118     {
119        return firstname;
120     }
121
122     public void setFirstname( String JavaDoc firstname )
123     {
124        this.firstname = firstname;
125     }
126
127     /**
128      * @ ejb.persistence
129      * column-name="lastname"
130      * jdbc-type="VARCHAR"
131      * sql-type="varchar(50)"
132      */

133     @Column(name="lastname", length=50)
134     public String JavaDoc getLastname( )
135     {
136        return lastname;
137     }
138
139     public void setLastname( String JavaDoc lastname )
140     {
141        this.lastname = lastname;
142     }
143
144     /**
145      * @ ejb.persistence
146      * column-name="email"
147      * jdbc-type="VARCHAR"
148      * sql-type="varchar(255)"
149      */

150     @Column(name="email", length=255)
151     public String JavaDoc getEmail( )
152     {
153        return email;
154     }
155
156     public void setEmail( String JavaDoc email )
157     {
158        this.email = email;
159     }
160
161     /**
162      * @ ejb.persistence
163      * column-name="telephone"
164      * jdbc-type="VARCHAR"
165      * sql-type="varchar(10)"
166      */

167     @Column(name="telephone", length=10)
168     public String JavaDoc getTelephone( )
169     {
170        return telephone;
171     }
172
173     public void setTelephone( String JavaDoc telephone )
174     {
175        this.telephone = telephone;
176     }
177
178     /**
179      * @ ejb.persistence
180      * column-name="language"
181      * jdbc-type="VARCHAR"
182      * sql-type="varchar(3)"
183      */

184     @Column(name="language", length=3)
185     public String JavaDoc getLanguage( )
186     {
187        return localeId;
188     }
189
190     public void setLanguage( String JavaDoc localeId )
191     {
192        this.localeId = localeId;
193     }
194
195     /**
196      * @ ejb.persistence
197      * column-name="street1"
198      * jdbc-type="VARCHAR"
199      * sql-type="varchar(50)"
200      */

201     @Column(name="street1", length=3)
202     public String JavaDoc getStreet1( )
203     {
204        return street1;
205     }
206
207     public void setStreet1( java.lang.String JavaDoc street1 )
208     {
209        this.street1 = street1;
210     }
211
212     /**
213      * @ ejb.persistence
214      * column-name="street2"
215      * jdbc-type="VARCHAR"
216      * sql-type="varchar(50)"
217      */

218     @Column(name="street2", length=50)
219     public String JavaDoc getStreet2( )
220     {
221        return street2;
222     }
223
224     public void setStreet2( String JavaDoc street2 )
225     {
226        this.street2 = street2;
227     }
228
229     /**
230      * @ ejb.persistence
231      * column-name="city"
232      * jdbc-type="VARCHAR"
233      * sql-type="varchar(25)"
234      */

235     @Column(name="city", length=25)
236     public java.lang.String JavaDoc getCity( )
237     {
238        return city;
239     }
240
241     public void setCity( String JavaDoc city )
242     {
243        this.city = city;
244     }
245
246     /**
247      * @ ejb.persistence
248      * column-name="state"
249      * jdbc-type="VARCHAR"
250      * sql-type="varchar(3)"
251      */

252     @Column(name="state", length=3)
253     public String JavaDoc getState( )
254     {
255        return state;
256     }
257
258     public void setState( String JavaDoc state )
259     {
260        this.state = state;
261     }
262
263     /**
264      * @ ejb.persistence
265      * column-name="zipcode"
266      * jdbc-type="VARCHAR"
267      * sql-type="varchar(10)"
268      */

269     @Column(name="zipcode", length=10)
270     public String JavaDoc getZipcode( )
271     {
272        return zipcode;
273     }
274
275     public void setZipcode( String JavaDoc zipcode )
276     {
277        this.zipcode = zipcode;
278     }
279
280     /**
281      * @ ejb.persistence
282      * column-name="country"
283      * jdbc-type="VARCHAR"
284      * sql-type="varchar(3)"
285      */

286     @Column(name="country", length=3)
287     public java.lang.String JavaDoc getCountry( )
288     {
289        return country;
290     }
291
292     public void setCountry( String JavaDoc country )
293     {
294        this.country = country;
295     }
296
297     /**
298      * @ ejb.persistence
299      * column-name="creditCardNumber"
300      * jdbc-type="VARCHAR"
301      * sql-type="varchar(25)"
302      */

303     @Column(name="creditCardNumber", length=25)
304     public String JavaDoc getCreditCardNumber( )
305     {
306        return creditCardNumber;
307     }
308
309     public void setCreditCardNumber( String JavaDoc creditCardNumber )
310     {
311        this.creditCardNumber = creditCardNumber;
312     }
313
314     /**
315      * @ ejb.persistence
316      * column-name="creditCardType"
317      * jdbc-type="VARCHAR"
318      * sql-type="varchar(25)"
319      */

320     @Column(name="creditCardType", length=25)
321     public String JavaDoc getCreditCardType( )
322     {
323        return creditCardType;
324     }
325
326     public void setCreditCardType( String JavaDoc creditCardType )
327     {
328        this.creditCardType = creditCardType;
329     }
330
331     /**
332      * @ ejb.persistence
333      * column-name="creditCardExpiryDate"
334      * jdbc-type="VARCHAR"
335      * sql-type="varchar(10)"
336      */

337     @Column(name="creditCardExpiryDate", length=10)
338     public String JavaDoc getCreditCardExpiryDate( )
339     {
340        return creditCardExpiryDate;
341     }
342
343     public void setCreditCardExpiryDate( String JavaDoc creditCardExpiryDate )
344     {
345        this.creditCardExpiryDate = creditCardExpiryDate;
346     }
347
348     /**
349      * @ ejb.interface-method
350      * @ ejb.relation
351      * name="customer-account"
352      * role-name="customer-has-account"
353      * target-ejb="Account"
354      * target-role-name="account-belongs_to-customer"
355      * target-cascade-delete="yes"
356      * @ ejb.value-object
357      * compose="xpetstore.domain.signon.model.AccountValue"
358      * compose-name="AccountValue"
359      * members="xpetstore.domain.signon.interfaces.Account"
360      * members-name="AccountValue"
361      * relation="external"
362      *
363      * @ jboss.relation
364      * fk-column="account_fk"
365      * related-pk-field="userId"
366      * fk-contraint="${db.foreign.key}
367      *
368      * @ weblogic.column-map
369      * foreign-key-column="account_fk"
370      */

371     @ManyToOne(cascade={CascadeType.ALL})
372     @JoinColumn(name="ACCOUNT_ID")
373     public Account getAccount( )
374     {
375        return account;
376     }
377
378     public void setAccount( Account account )
379     {
380        this.account = account;
381     }
382     
383     public String JavaDoc toString()
384     {
385        StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(200);
386        buffer.append("[Customer: userId " + userId);
387        buffer.append(", email " + email);
388        buffer.append(", account " + account);
389        buffer.append("]");
390        
391        return buffer.toString();
392     }
393 }
394
Popular Tags