1 package xpetstore.domain.customer.ejb; 2 3 import javax.ejb.CreateException ; 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 39 @Entity(name="Customer") 40 @Table(name="T_CUSTOMER") 41 public class Customer 42 { 43 private String userId; 44 private String firstname; 45 private String lastname; 46 private String email; 47 private String telephone; 48 private String localeId; 49 private String street1; 50 private String street2; 51 private String city; 52 private String state; 53 private String zipcode; 54 private String country; 55 private String creditCardNumber; 56 private String creditCardExpiryDate; 57 private String 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 userId, String firstname, String lastname, String email, String telephone, String localeId, String street1, String street2, String city, String state, String zipcode, String country, String creditCardNumber, String creditCardType, String 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 98 @Id 99 @Column(name="userId", length=10) 100 public String getUserId( ) 101 { 102 return userId; 103 } 104 105 public void setUserId( String userId ) 106 { 107 this.userId = userId; 108 } 109 110 116 @Column(name="firstname", length=50) 117 public String getFirstname( ) 118 { 119 return firstname; 120 } 121 122 public void setFirstname( String firstname ) 123 { 124 this.firstname = firstname; 125 } 126 127 133 @Column(name="lastname", length=50) 134 public String getLastname( ) 135 { 136 return lastname; 137 } 138 139 public void setLastname( String lastname ) 140 { 141 this.lastname = lastname; 142 } 143 144 150 @Column(name="email", length=255) 151 public String getEmail( ) 152 { 153 return email; 154 } 155 156 public void setEmail( String email ) 157 { 158 this.email = email; 159 } 160 161 167 @Column(name="telephone", length=10) 168 public String getTelephone( ) 169 { 170 return telephone; 171 } 172 173 public void setTelephone( String telephone ) 174 { 175 this.telephone = telephone; 176 } 177 178 184 @Column(name="language", length=3) 185 public String getLanguage( ) 186 { 187 return localeId; 188 } 189 190 public void setLanguage( String localeId ) 191 { 192 this.localeId = localeId; 193 } 194 195 201 @Column(name="street1", length=3) 202 public String getStreet1( ) 203 { 204 return street1; 205 } 206 207 public void setStreet1( java.lang.String street1 ) 208 { 209 this.street1 = street1; 210 } 211 212 218 @Column(name="street2", length=50) 219 public String getStreet2( ) 220 { 221 return street2; 222 } 223 224 public void setStreet2( String street2 ) 225 { 226 this.street2 = street2; 227 } 228 229 235 @Column(name="city", length=25) 236 public java.lang.String getCity( ) 237 { 238 return city; 239 } 240 241 public void setCity( String city ) 242 { 243 this.city = city; 244 } 245 246 252 @Column(name="state", length=3) 253 public String getState( ) 254 { 255 return state; 256 } 257 258 public void setState( String state ) 259 { 260 this.state = state; 261 } 262 263 269 @Column(name="zipcode", length=10) 270 public String getZipcode( ) 271 { 272 return zipcode; 273 } 274 275 public void setZipcode( String zipcode ) 276 { 277 this.zipcode = zipcode; 278 } 279 280 286 @Column(name="country", length=3) 287 public java.lang.String getCountry( ) 288 { 289 return country; 290 } 291 292 public void setCountry( String country ) 293 { 294 this.country = country; 295 } 296 297 303 @Column(name="creditCardNumber", length=25) 304 public String getCreditCardNumber( ) 305 { 306 return creditCardNumber; 307 } 308 309 public void setCreditCardNumber( String creditCardNumber ) 310 { 311 this.creditCardNumber = creditCardNumber; 312 } 313 314 320 @Column(name="creditCardType", length=25) 321 public String getCreditCardType( ) 322 { 323 return creditCardType; 324 } 325 326 public void setCreditCardType( String creditCardType ) 327 { 328 this.creditCardType = creditCardType; 329 } 330 331 337 @Column(name="creditCardExpiryDate", length=10) 338 public String getCreditCardExpiryDate( ) 339 { 340 return creditCardExpiryDate; 341 } 342 343 public void setCreditCardExpiryDate( String creditCardExpiryDate ) 344 { 345 this.creditCardExpiryDate = creditCardExpiryDate; 346 } 347 348 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 toString() 384 { 385 StringBuffer buffer = new StringBuffer (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 |