KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > annotations > embedded > RegionalArticlePk


1 //$Id: RegionalArticlePk.java,v 1.1 2005/05/12 13:33:32 epbernard Exp $
2
package org.hibernate.test.annotations.embedded;
3
4 import javax.persistence.AccessType;
5 import javax.persistence.Embeddable;
6 import java.io.Serializable JavaDoc;
7
8 /**
9  * Regional article pk
10  * @author Emmanuel Bernard
11  */

12 @Embeddable(access = AccessType.FIELD)
13 public class RegionalArticlePk implements Serializable JavaDoc {
14     /** country iso2 code */
15     public String JavaDoc iso2;
16     public String JavaDoc localUniqueKey;
17
18     public int hashCode() {
19         //this implem sucks
20
return (iso2 + localUniqueKey).hashCode();
21     }
22
23     public boolean equals(Object JavaDoc obj) {
24         //iso2 and localUniqueKey are expected to be set in this implem
25
if (obj != null && obj instanceof RegionalArticlePk) {
26             RegionalArticlePk other = (RegionalArticlePk) obj;
27             return iso2.equals(other.iso2) && localUniqueKey.equals(other.localUniqueKey);
28         }
29         else {
30             return false;
31         }
32     }
33 }
34
Popular Tags