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