1 22 package org.jboss.ejb3.test.composite; 23 24 import javax.persistence.Embeddable; 25 26 32 @Embeddable 33 public class CustomerPK implements java.io.Serializable 34 { 35 private long id; 36 private String name; 37 38 39 public CustomerPK() 40 { 41 } 42 43 public CustomerPK(long id, String name) 44 { 45 this.id = id; 46 this.name = name; 47 } 48 49 public long getId() 50 { 51 return id; 52 } 53 54 public void setId(long id) 55 { 56 this.id = id; 57 } 58 59 public String getName() 60 { 61 return name; 62 } 63 64 public void setName(String name) 65 { 66 this.name = name; 67 } 68 69 public int hashCode() 70 { 71 return (int) id + name.hashCode(); 72 } 73 74 public boolean equals(Object obj) 75 { 76 if (obj == this) return true; 77 if (!(obj instanceof CustomerPK)) return false; 78 if (obj == null) return false; 79 CustomerPK pk = (CustomerPK) obj; 80 return pk.id == id && pk.name.equals(name); 81 } 82 } 83 | Popular Tags |