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 445639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:23:28+00:00 2026-05-12T21:23:28+00:00

If my understanding of Aggregate Roots is correct, the root should be responsible also

  • 0

If my understanding of Aggregate Roots is correct, the root should be responsible also for deleting one of its “children”. That would seemingly translate into something like this:

order.removeOrderLine(23);

Which would effectively remove it from the collection. However, how is this persisted? Is my ORM’s UnitOfWork supposed to detect that something went missing in that collection, and then delete it from the database?

Should I have removeOrderLine a method of the OrderRepository instead?

  • 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-12T21:23:28+00:00Added an answer on May 12, 2026 at 9:23 pm

    Your Unit of Work should usually take care of this, but it depends on its implementation, specifically on the way it detects changes. Some unit of work implementations (i.e. Hibernate) keeps a copy of the aggregate before you changed it, so at the end of business transaction (when you call something like unitOfWork.PersistAll()), it tries to match current version of all objects (and collections) against the original version.

    Other way is to have your domain entities more coupled with your unit of work so that the entity notified the unit of work when something changes (i.e. the order.removeOrderLine method would notify the unit of work about the change).

    There are multiple ways how to implement UoW change detection. Have a look at several implementations for hibernat for inspiration.

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

Sidebar

Related Questions

Understanding that I should probably just dig into the source to come up with
My understanding is that Processing.js converts Processing code into javascript. But if one does
My understanding is that Thread.Abort should raise a ThreadAbortException on a blocked thread, however
Understanding that if someone had JavaScript disabled the site would not work then is
My understanding of Comet is that its a server-side AJAX request. My understanding of
My understanding of Dart leads me to believe that this 'cast' should not affect
My understanding is that when using && as an mathematical operation in Java, if
My understanding is that OpenSSL is deprecated in OSX 10.7 in favor of Common
My understanding is that threads in theory are executed in parallel. JVM decides; when
My understanding is that Java's implementation of regular expressions is based on Perl's. However,

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.