1 package org.hibernate.test.annotations.manytoone; 3 4 import javax.persistence.AccessType; 5 import javax.persistence.Column; 6 import javax.persistence.Embeddable; 7 import java.io.Serializable ; 8 9 12 @Embeddable(access = AccessType.FIELD) 13 public class ParentPk implements Serializable { 14 @Column(length=50) 15 String firstName; 16 String lastName; 17 18 19 boolean isMale; 21 22 public int hashCode() { 23 return firstName.hashCode() + lastName.hashCode() + (isMale?0:1); 25 } 26 27 public boolean equals(Object obj) { 28 if (obj != null && obj instanceof ParentPk) { 30 ParentPk other = (ParentPk) obj; 31 return firstName.equals(other.firstName) 32 && lastName.equals(other.lastName) 33 && isMale == other.isMale; 34 } 35 else { 36 return false; 37 } 38 } 39 } 40 | Popular Tags |