Couldn't an "adding them together" solution like this have possible effect
of going out of the range on int (greater than Integer.MAX_VALUE)?
>From: Avi Kivity <[EMAIL PROTECTED]>
>Reply-To: A mailing list for Enterprise JavaBeans development
><[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: hashCode for entity bean with multiple pk columns
>Date: Thu, 29 Jun 2000 18:44:26 +0200
>
> >
> > 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".
>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
===========================================================================
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".