Data Model: Review equals
and hashCode
methods for persistent objects
#162
Labels
invalid
This doesn't seem right
equals
and hashCode
methods for persistent objects
#162
For persistent objects the
equals
method may not work as expected. Most of the classes (with the notable exception of the recently correctedProduct
andProcessingFacility
) contain the code:Probably this should read:
The first variant effectively makes comparing loaded objects and transient objects impossible (because the database IDs differ), and if the IDs match, the subsequent attribute-based check is more or less redundant. Presumably a logic like the general
if (this == obj) return true;
(as in the second variant) is more appropriate.Since the code worked up to now, a careful review and test is required before performing a general change of the
equals
methods.The text was updated successfully, but these errors were encountered: