-
1. Re: BUG: FindByPrimaryKey fails to find object when using co
tbfmicke Jul 24, 2002 12:45 PM (in response to zommick)One explanation might be that you have forgotten to write the equals and hashcode methods in your primary key class. (Or have a but in them somewhere).
Regards -
2. Re: BUG: FindByPrimaryKey fails to find object when using co
zommick Jul 24, 2002 12:52 PM (in response to zommick)As you can see, the hashcode and equals appear to be fine.
public class RequestPK implements java.io.Serializable {
public Integer requestId;
public Integer recordingId;
public Integer getRequestId() {
return requestId;
}
public Integer getRecordingId() {
return recordingId;
}
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof RequestPK)) {
return false;
}
RequestPK other = (RequestPK)obj;
if ( this.requestId.intValue() == other.requestId.intValue()
&& this.recordingId.intValue() == other.recordingId.intValue() ) {
return true;
}
else {
return false;
}
}
public int hashCode() {
return (requestId.intValue() + " " + recordingId.intValue()).hashCode();
}
public String toString() {
return requestId.intValue() + " " + recordingId.intValue();
}
public RequestPK() {}
public RequestPK( Integer requestId, Integer recordingId ) {
this.requestId = requestId;
this.recordingId = recordingId;
}
}