Background
BaseEntity.equals() compares ID and type name, while hashCode() currently also includes version. Equal entities with different versions may therefore produce different hash codes, which breaks hash-based collections.
Scope
Add focused equality-contract tests and make the smallest correction required.
Test cases
- Same instance is equal to itself.
- Same concrete entity type and ID are equal.
- Equal entities have identical hash codes even when versions differ.
- Different IDs are not equal.
- Different concrete entity classes are not equal.
- HashSet lookup succeeds for an equal entity instance.
Acceptance criteria
- The tests demonstrate the current contract violation before the correction.
equals() and hashCode() use the same identity fields after the fix.
- No persistence or runtime fixture is involved.
Background
BaseEntity.equals()compares ID and type name, whilehashCode()currently also includes version. Equal entities with different versions may therefore produce different hash codes, which breaks hash-based collections.Scope
Add focused equality-contract tests and make the smallest correction required.
Test cases
Acceptance criteria
equals()andhashCode()use the same identity fields after the fix.