1 package org.hibernate.test.annotations.cid; 3 4 import java.io.Serializable ; 5 import javax.persistence.AccessType; 6 import javax.persistence.Embeddable; 7 import javax.persistence.JoinColumn; 8 import javax.persistence.JoinColumns; 9 import javax.persistence.ManyToOne; 10 11 15 @Embeddable(access=AccessType.FIELD) 16 public class ChildPk implements Serializable { 17 public int nthChild; 18 @ManyToOne() 19 @JoinColumns ({ 20 @JoinColumn(name="parentLastName", referencedColumnName = "p_lname"), 21 @JoinColumn(name="parentFirstName", referencedColumnName = "firstName") 22 }) 23 public Parent parent; 24 25 public boolean equals(Object o) { 26 if (this == o) return true; 27 if (!(o instanceof ChildPk)) return false; 28 29 final ChildPk childPk = (ChildPk) o; 30 31 if (nthChild != childPk.nthChild) return false; 32 if (!parent.equals(childPk.parent)) return false; 33 34 return true; 35 } 36 37 public int hashCode() { 38 int result; 39 result = nthChild; 40 result = 29 * result + parent.hashCode(); 41 return result; 42 } 43 } 44 | Popular Tags |