/******************************************************************************* * Copyright (c) 2016 IBM Corporation. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 * which accompanies this distribution. * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html * and the Eclipse Distribution License is available at * http://www.eclipse.org/org/documents/edl-v10.php. * * Contributors: * 08/24/2016 - Will Dazey * - 500145 : Nested Embeddables Test ******************************************************************************/ package org.eclipse.persistence.jpa.embeddable.model; import javax.persistence.Embeddable; import javax.persistence.Embedded; @Embeddable public class OrderPK { @Embedded private Address billingAddress; @Embedded private Address shippingAddress; public OrderPK() { } public Address getBillingAddress() { return billingAddress; } public void setBillingAddress(Address billingAddress) { this.billingAddress = billingAddress; } public Address getShippingAddress() { return shippingAddress; } public void setShippingAddress(Address shippingAddress) { this.shippingAddress = shippingAddress; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((billingAddress == null) ? 0 : billingAddress.hashCode()); result = prime * result + ((shippingAddress == null) ? 0 : shippingAddress.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; OrderPK other = (OrderPK) obj; if (billingAddress == null) { if (other.billingAddress != null) return false; } else if (!billingAddress.equals(other.billingAddress)) return false; if (shippingAddress == null) { if (other.shippingAddress != null) return false; } else if (!shippingAddress.equals(other.shippingAddress)) return false; return true; } }