This content has been marked as final.
Show 3 replies
-
1. Re: JBoss 3.2.0 says must override equals()
gsinohio Apr 24, 2003 4:04 PM (in response to gsinohio)BTW, the code is out of the PrimaryKey class which is what JBoss3.2.0 is complaining about.
-
2. Re: JBoss 3.2.0 says must override equals()
adrian.brock Apr 24, 2003 4:29 PM (in response to gsinohio)super.equals(otherKey));
I assume is the implementation from
java.lang.Object
Your implementation is incorrect, you are
checking object reference equality not object
equality.
i.e. this == otherKey
new CustomerEntityKey() == new CustomerEntityKey()
is false
You should have something like:
public class PrimaryKey
{
public String myKey1;
public boolean equals(Object test)
{
if (test == this) return true;
if (test == null || !(test instanceof PrimaryKey)) return false;
PrimaryKey other = (PrimaryKey) test;
return this.myKey1.equals(other.myKey1);
}
public int hashCode()
{
return myKey1.hashCode();
}
}
Regards,
Adrian -
3. Re: JBoss 3.2.0 says must override equals()
gsinohio Apr 24, 2003 4:57 PM (in response to gsinohio)That took care of it. Thanks!!!