During the presentation yesterday (25-09-2008) there was a quick discussion about generating an equals method (along with toString, hashCode and more).
If its decided an equals method must be created (you can still create a stub) then please read this article:
It states the current implementations of Eclipse and MyEclipse (which can both generate 'equals' methods for you) do it wrong to some degree.
Eclipse does this:
if (getClass() != obj.getClass()) return false;
This goes wrong with proxies, because getClass isn't the same in a proxy as the concrete (super) class.
MyEclipse solved this with generating this:
if (!(obj instanceof MyClass)) return false;
But... MyEclipse goes on generating comparisons for (some? all public?) fields in the object, for example:
if (!name.equals(other.name)) return false;
This doesn't work for Hibernate proxies, they don't have the time to (lazy) load the fields, you should instead use:
if (!name.equals(other.getName())) return false;
So if we combine this knowledge I think we can generate valid 'equals' methods in Mod4J. You start out by comparing the class the way MyEclipse does, and then generate comparisons for all fields mapped to the database (which we know from the model). These fields combined represent the state of a domain-object.