1

We are refactoring an existing application using Spring Data JPA. There are close to 250 static code database tables which can be referred by other aggregate roots. In order to attach a code table to an aggregate root, we need to access the particular code table record. Does that mean we should create 250 repositories? I mean a repo per static code table since it's an aggregate root itself?

I saw this question, which is kind of similar, but in my case I have a lot of static tables.

bluelurker
  • 1,353
  • 3
  • 19
  • 27

1 Answers1

1

In the context of [tag:Domain Driven Design], REPOSITORY should be understood as described by Eric Evans in his 2003 book. The repository pattern is introduced and described in chapter 6, which is about "The Life Cycle of a Domain Object".

So if your static code tables have life cycles that are managed by your domain model, then yes the should probably be expressed as aggregates with their own repositories.

On the other hand, if they are just reference data, then using the repository pattern isn't particularly important. You'll want some sort of implementation hiding boundary so that your application is insulated from the details of how to access the reference data, but that boundary doesn't particularly need to be a repository.

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91
  • In the end, we decided to create a repo per table since these codes will be updated by the admin user of the application. – bluelurker Mar 25 '20 at 17:14