Skip to content

Refactor Employee-Section relationship #20

@NikosPoly

Description

@NikosPoly

Currently the Employee-Section relationship is inconsistent and bidirectional:

  • Employee has a free text String section field instead of a proper reference
  • Section stores a List employeeIds creating a bidirectional relationship
    that requires keeping two places in sync

The relationship should be owned by Employee only, same pattern as Loan owning
references to Book and Customer.

Tasks

  • Replace String section in Employee with String sectionId referencing the Section MongoDB ID
  • Remove employeeIds list from Section — employee owns the relationship
  • Add findBySectionId(String sectionId) to EmployeeRepository
  • Update EmployeeService and EmployeeController accordingly
  • Update SectionService and SectionController accordingly

Note

This is a breaking change — existing employee documents will need migration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    code qualityMake the code cleaner without changing behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions