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] New: - HashCodeBuilder failed to generate unique hashcode
Date Tue, 23 Nov 2004 18:25:13 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

           Summary: HashCodeBuilder failed to generate unique hashcode
           Product: Commons
           Version: 2.0 Final
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Lang
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: bsun@ball.com
                CC: bsun@ball.com


HashCodeBuilder class failed to generate unique hashcode for objects.

Here are codes to reproduce the problem:

import org.apache.commons.lang.builder.HashCodeBuilder;

public class Person
{
    public int id;
    public String name;

    public Person(int id, String name)
    {
        this.id=id;
        this.name = name;
    }

    public int hashCode()
    {
        return new HashCodeBuilder(17,37).
                append(id).
                append(name).
                toHashCode();
    }
}

package com.ball.edi.prototype;

public class TestHashCode
{
    static public void main(String args[])
    {
        Person p1=new Person(214686, "03065");
        Person p2=new Person(214691, "03006");

        System.out.println("The hashcode for p1 is " + p1.hashCode());
        System.out.println("The hashcode for p2 is " + p2.hashCode());
    }
}

When you ran TestHashCode class, you will get 

The hashcode for p1 is 53862859
The hashcode for p2 is 53862859

I found this problem when I am using OJB.

Thanks.

-- 
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