12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3 ■ OBJECT-RELATIONAL MAPPINGpublic void setStreet1(String street1) {this.street1 = street1;}public String getStreet2() {return street2;}public void setStreet2(String street2) {this.street2 = street2;}@Column(nullable = false, length = 50)public String getCity() {return city;}public void setCity(String city) {this.city = city;}@Column(length = 3)public String getState() {return state;}public void setState(String state) {this.state = state;}@Column(name = "zip_code", length = 10)public String getZipcode() {return zipcode;}public void setZipcode(String zipcode) {this.zipcode = zipcode;}}public String getCountry() {return country;}public void setCountry(String country) {this.country = country;}Explicitly setting the access type on embeddables is strongly recommended to avoid mapping errorswhen an embeddable is embedded by multiple entities. Let’s extend our model by adding an Orderentity as shown in Figure 3-5. Address is now embedded by Customer (the home address of the customer)and Order (the delivery address).90

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!