1 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 21 { 22 private int id; 23 private Name name; 24 private String street; 25 private String city; 26 private String state; 27 private String zip; 28 29 public Customer() 30 { 31 } 32 33 public Customer(String first, String last, String street, String city, String state, String 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 getStreet() 71 { 72 return street; 73 } 74 75 public void setStreet(String street) 76 { 77 this.street = street; 78 } 79 80 @Column(name = "CITY") 81 public String getCity() 82 { 83 return city; 84 } 85 86 public void setCity(String city) 87 { 88 this.city = city; 89 } 90 91 @Column(name = "STATE") 92 public String getState() 93 { 94 return state; 95 } 96 97 public void setState(String state) 98 { 99 this.state = state; 100 } 101 102 @Column(name = "ZIP") 103 public String getZip() 104 { 105 return zip; 106 } 107 108 public void setZip(String zip) 109 { 110 this.zip = zip; 111 } 112 } 113 | Popular Tags |