Hi,
hasCode() doesn't have to (or shouldn't) return an unique int. It should
return well distributed integer, and always the same for the same keys.
So you can implement you hashCode() like this:
StringBuffer buff = new StringBuffer();
buff.append(String.valueOf(key1));
buff.append(String.valueOf(key2));
buff.append(String.valueOf(key3));
buff.append(String.valueOf(key4));
buff.append(String.valueOf(key5));
return buff.toString().hashCode();
/Kaj
> -----Ursprungligt meddelande-----
> Fr�n: ������ [mailto:[EMAIL PROTECTED]]
> Skickat: Friday, July 28, 2000 11:53 PM
> Till: [EMAIL PROTECTED]
> �mne: hashcode() problem in multi fields pk class
>
>
> hi,
> I'm trying to implement CMP entity bean with multi-fields
> Primarky Key class. That is,
> In PK class , there are 5 primary key fields. It seems like
> different from that of single-field PK class becasue I have
> to override hashcode() method with these fields which is
> required to return unique int value.
> I want to see a 'well-done' example
>
> Any comment will be very helpful.
>
> have a nice day!!
>
> ==================================================
> �츮 ���ͳ�, Daum
> ��� ���� ���� E-mail �ּ� �Ѹ��ϳ�
> ������ �ѱ� �˻����� Daum FIREBALL
> http://www.daum.net
>
> ==============================================================
> =============
> 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".
>
===========================================================================
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".