>
> Anyone have suggestion regarding standard way to write int
> hashCode() method
> now required in PK when one has multiple PK's.
>
> If I have one PK value (Integer myInteger) I do this:
>
> public int hashCode() {
>   return myInteger.hashCode();
> }
>
> How about if I have two Ingegers and a Timestamp making up my
> PK, what is a
> nice simple clean way to write hashCode method?

how about

public int hashCode() {
    int result = 0;
    result = result * 127 + field1.hashCode();
    result = result * 127 + field2.hashCode();
    result = result * 127 + field3.hashCode();
    result = result * 127 + field4.hashCode();
    result = result * 127 + field5.hashCode();
    return result;
}

?

- Avi
--
s/\be(\w+)/e-\1/g;

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to