-
1. Re: Deploying with Primary Key class
klaust Dec 19, 2001 4:48 AM (in response to simteq)try like this:
public class anmeldungPK implements java.io.Serializable {
public String man;
public String ak;
public String pnr;
public anmeldungPK() { }
public anmeldungPK(String man, String ak, String pnr) {
this.man = man;
this.ak = ak;
this.pnr = pnr;
}
public boolean equals(Object other) {
if( other instanceof anmeldungPK ) {
return(
man.equals(((anmeldungPK)other).man) && ak.equals(((anmeldungPK)other).ak) && pnr.equals(((anmeldungPK)other).pnr)
);
}
return false;
}
public int hashCode() {
return(
man.hashCode() +
ak.hashCode() +
pnr.hashCode()
);
}
public String toString() {
return(man+"|"+ak+"|"+pnr);
}
}
hope that helps -
2. Re: Deploying with Primary Key class
pazu Dec 20, 2001 8:57 AM (in response to simteq)Take a look at Object.hashCode() javadoc. The short story: hashCode() should return a integer suitable to be used as key in a hash table.