About making equals() and hashCode(). One good way is to use the builders in jakarta commons-lang. They produce results in accordance to the very good guidelines presented in the Effective Java book (search google and you'll find some sample chapters). Additionally, keeping in mind
http://www.hibernate.org/109.html, i.e. prefer to use some static data instead of object id, a good equals and hashCode for some class Foo could be (assuming the class contains creationDate and creatorId properties which presumably don't change):
Code:
public boolean equals(Object o) {
if (!(o instanceof Foo)) {
return false;
}
Foo rhs = (Foo) o;
return new EqualsBuilder()
.append(creationDate, rhs.creationDate)
.append(creatorId, rhs.creatorId)
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder(23, 43)
.append(creationDate)
.append(creatorId)
.toHashCode();
}