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

  • SEARCH
  • Home
  • 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 7736465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:44:18+00:00 2026-06-01T07:44:18+00:00

Let’s take an example where we have two entities: ServiceProvider and TelephoneNumber . The

  • 0

Let’s take an example where we have two entities: ServiceProvider and TelephoneNumber. The system allows service providers to add telephone numbers. Each telephone number added by a service provider is represented by an instance of TelephoneNumber. So, I have an association between these two entities. For now, I’ve decided that a TelephoneNumber instance is associated to exactly one service provider. I also decided that these two entities belong to the same aggregate with ServiceProvider being the aggregate root (one argument is that the TelephoneNumber lifecycle depends on the ServiceProvider entity).

My question is about the traversal direction of the association. I know in advance that a service provider may add many millions of telephone numbers.

If the traversal direction of the association is from ServiceProvider to TelephoneNumber, how to implement in an efficient way? Storing a set of telephone numbers in the ServiceProvider entity would be inefficient (especially for memory). Lazy loading may be used but it would limit the implementation options by using frameworks that support it (e.g. Hibernate).

In a known example where we have Customer and Order entities, a unidirectional association from Order to Customer is often chosen. If the traversal direction of the association is from TelephoneNumber to ServiceProvider, how to implement the CRUD operations for TelephoneNumber? I guess we need to use a TelephoneNumberRepository? But, I often saw that repositories should be defined only for aggregate roots since we generally get the aggregate root instance and we communicate with the domain model through it.

Thanks

  • 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-06-01T07:44:19+00:00Added an answer on June 1, 2026 at 7:44 am

    Since you need to access phone numbers according to some criteria, I wouldn’t be shocked to see a PhoneNumberRepository even if it’s not an Aggregate root.

    On the other hand, you could have the appropriate FindPhoneNumberBy…() methods directly in ServiceProvider. What bothers me there is that you can’t load a huge number phone numbers in memory at once, which means you would have to introduce some kind of performance management (lazy loading/enumeration, etc.) in ServiceProvider, breaking the separation of concerns.

    The advantage of a separate Repository is that while the interface would be in the Domain layer, its concrete implementation would reside in the Infrastructure layer, which nicely decouples the contracts of FindPhoneNumberBy…() methods from the underlying fetching tricks. All in all, I can’t really see a more legitimate candidate than a Repository to handle that kind of stuff.

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

Sidebar

Related Questions

Let's say I have two tables orgs and states orgs is (o_ID, state_abbr) and
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have two Entity classes: SocialApp and SocialAppType In SocialApp I have
Let's take a common example how a haskell function can be called from a
Let say I have two UIViews: View1: - bounds: 0, 0, 20, 20 -
Let's say I have two assemblies: BusinessLogic and Web. BusinessLogic has an application setting
Let's say for example i have URL containing the following percent encoded character :
Let's say I'm building a data access layer for an application. Typically I have
Let's say you have a class called Customer, which contains the following fields: UserName
Let me try to explain what I need. I have a server that is

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.