commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32364] - [lang] HashCodeBuilder failed to generate unique hashcode
Date Tue, 23 Nov 2004 22:21:45 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32364>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32364





------- Additional Comments From ggregory@seagullsw.com  2004-11-23 23:21 -------
Hi,

If you want to use and int and a String together as a primary key/hash code,
then I think you will run into issues unless the value range of id and name can
be reduced. 

Hash codes are ints, so you can have as many unique hash codes for a set of
objects as you can have ints, which is Integer.MIN_VALUE to Integer.MAX_VALUE. A
simplification would be to say that you can have Integer.MAX_VALUE * 2 hash codes.

If your int id can have all int legal values AND you can have any String to
create your primary keys then you'll run out of int hash codes to cover all the
cases.

So, defining the legal range of values for id and name is where to start. From
there, a proper hashCode() method can be coded. We can then see how the
HashCodeBuilder class be improved to help you.



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message