Skip to content

test(core): enforce the BaseEntity equals and hashCode contract #26

Description

@philipgreat

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjavaPull requests that update java code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions