On Nov 3, 2005, at 10:40 AM, Anil Gangolli wrote:
A bit more on equals().
(1) We have a default reflective implementation of equals in
PersistentObject (I think), and I believe it is uses field-level
reflection, not "bean-style" property getter introspection/reflection.
This may be dangerous..
Since we've now turned off lazy-loading at the class level, I hope
we're back to the same danger-level we had in 1.x.
(2) When we do override equals(Object other), we have a tendency to
reach into other.field for comparisons. I don't know if Hibernate
proxies are "smart" enough to instantiate both x and y when
x.equals(y) is invoked, so we should also use getters there to be
safe.
(3) Hibernate recommends a weak "semi-unique" equals based on business
keys only, for a reason I haven't fully grasped yet. We tend to
implement traditional strong equals. This might be something to
reexamine.
Yes, I agree. The equals() methods in most POJOs were originally
generated by the XDoclet EJB Data Transfer Object generator and they
were simply left in-place when we stopped generating our POJOs.
- Dave