On 9/19/06, Allen Gilliland <[EMAIL PROTECTED]> wrote:
back when I was working on some of the backend refactoring work for
Roller 2.2 I realized that our implementations of equals() and
hashCode() in our pojos does not actually conform to Hibernate's (and
other ORM tools) suggestion of using business key equality.

http://www.hibernate.org/hib_docs/v3/reference/en/html/persistent-classes.html#persistent-classes-equalshashcode

In a nutshell we are doing a couple things wrong ...

1. we are using the 'id' of an object in the implementation of equals()
and hashCode() and that's not recommended because our ids are generated
only after being saved to the db, so you would get problems when mixing
transient and persistent/detached objects in the same collection.

2. we are using way more properties for comparison in our
implementations of equals() and hashCode() than we really need.

So, I would like to suggest that we clean up our pojos a bit by doing 2
things ...

1. remove the generic equals() method from the PersistentObject class.

2. determine the proper business key for each pojo and reimplement
equals() and hashCode() for each pojo using its proper business key.

thoughts?  objections?

+1 - sounds good to me.  My only question would be do we have good
enough tests to ensure we don't break anything and end up with
duplicate objects in the database?

Matt


-- Allen

Reply via email to