Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4048738
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:51:18+00:00 2026-05-20T13:51:18+00:00

It is recommended to have one repository per aggregate. However, I have a case

  • 0

It is recommended to have one repository per aggregate.

However, I have a case where the same aggregate object can be fetched from 2 heterogeneous data stores. For the background, that object is:

  1. fetched from data store A (remote & read-only)
  2. presented to the user for validation
  3. on validation, imported into data store B (local & read-write)
  4. it can be fetched from and modified in data store B

Obviously (or not), I can’t have a unique aggregate repository for that – at some point I need to know from which data store the object is fetched.

Given that the domain layer should ignore the infrastructure, my particular case breaks somehow my understanding of how the repository pattern and DDD in general should be properly implemented.

Did I get something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:51:19+00:00Added an answer on May 20, 2026 at 1:51 pm

    Did I get something wrong?

    Seems to me what you got wrong is having two data stores for the same data.

    If indeed there’s a good reason for this redundancy, the two aggregates must be different in some way, and that might justify considering them as separate aggregates and having two repositories.

    If you want to treat them as a single aggregate, a single repository should know how to disambiguate and deal with the correct datastore, but encapsulate that knowledge of datastores away from your domain model.

    EDIT:

    In the situation as explained in comments, where one datastore is read-only and the other a local modifiable copy, having two datastores is in fact forced on you. Your repository needs to know about both datastores and use the remote read-only store only if it does not find something locally. Immediately upon retrieving something from the remote, it should save it to the local and thereafter use the local copy.

    This logic is sort of a caching proxy, but not exactly, as the remote is read-only and the local is read-write. It might contain enough logic to be extracted to a service used by the repository, but shouldn’t be exposed to the domain.

    This situation also has some risks that you need to think about. Once you’ve saved something locally, you have two versions of the same data, which will get out of synch. What do you do if someone with write access on the remote changes it after you’ve changed your local?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can one safely have the same SVN repository served by both svnserve and httpd
When using the repository pattern is it recommended to have one Repository class for
Can you recommend a single downloadable video ( one that you have actually watched
I knew than one of the benefits from using repository pattern make it easy
I'm a one-person IT department managing our company's website and recently recommended they have
Here is the scenario that I have. I have a cvs repository in one
In C++ it's recommended to have const-correctness everywhere. But since in .Net world, the
I'm the TFS admin at my company. In the past, I have recommended a
I have two checkboxes (Recommended and Others) which have peoples names (concatenated, i.e. John
I have heard that using exception trapping is not a recommended practice for number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.