F
Franck
Hi,
Each instance of MyClass should be persisted in table,
MyClass has a private field "key" (long type), with accessors, that is
mapped with the key of the table.
I would like to simplify the use of collections of instances of MyClass
(methods contains(), retains() etc...)
Should I have problems if i redefine equals() and hashcode() on MyClass like
that :
public boolean equals(Object o) {
if (!(o instanceof MyClass))
return false;
MyClass f = (MyClass)o;
return f.getKey() == this.getKey();
}
public int hashcode() {
return (new Long(this.getKey())).intValue()
}
Thanks for your answers
Each instance of MyClass should be persisted in table,
MyClass has a private field "key" (long type), with accessors, that is
mapped with the key of the table.
I would like to simplify the use of collections of instances of MyClass
(methods contains(), retains() etc...)
Should I have problems if i redefine equals() and hashcode() on MyClass like
that :
public boolean equals(Object o) {
if (!(o instanceof MyClass))
return false;
MyClass f = (MyClass)o;
return f.getKey() == this.getKey();
}
public int hashcode() {
return (new Long(this.getKey())).intValue()
}
Thanks for your answers