Search code examples
ormdomain-driven-designddd-repositoriesdomain-object

Should child entity classes have their own repositories?


I have several classes inheriting from an Admin class: Manager, Translator, etc.

Admin is an aggregate, so should have its own Repository. However, some methods to find Managers or Translators might be specific to these classes. Others might be common to all Admins.

What is the best practice here? Should I:

  • put all the methods to find Admins in one Repository?
  • or mimic the hierarchy of domain model classes with a hierarchy of Repositories, then having a ManagerRepository and a TranslatorRepository extending an AdminRepository?

Solution

  • As I see - it doesn't matter that much.

    I would stick with one AdminRepository unless it bloats and begs for decomposition.