Questions tagged [aggregateroot]

A cluster of associated objects that are treated as a unit for the purpose of data changes. External references are restricted to one member of the Aggregate, designated as the root. A set of consistency rules applies within the Aggregate's boundaries.

aggregateroot
Filter by
Sorted by
Tagged with
601 votes
11 answers
202k views

What's an Aggregate Root?

I'm trying to get my head around how to properly use the repository pattern. The central concept of an Aggregate Root keeps coming up. When searching both the web and Stack Overflow for help with what ...
Dinah's user avatar
  • 53.4k
35 votes
1 answer
22k views

Repository Pattern with Entity Framework 4.1 and Parent/Child Relationships

I still have some confusion with the Repository Pattern. The primary reason why I want to use this pattern is to avoid calling EF 4.1 specific data access operations from the domain. I'd rather call ...
jodev's user avatar
  • 749
29 votes
3 answers
13k views

Aggregate Root references other aggregate roots

I'm currently working a lot with DDD, and I'm facing a problem when loading/operating on aggregate roots from other aggregate roots. For each aggregate root in my model, I also have a repository. The ...
tschmuck's user avatar
  • 533
26 votes
3 answers
18k views

Avoid Unit of Work pattern in domain driven design

I have read this and it makes me think twice...: "Avoid unit of work pattern. Aggregate roots should define transaction boundaries." Why should someone avoid the UOW pattern applying domain driven ...
Elisabeth's user avatar
  • 20.9k
25 votes
3 answers
18k views

Can aggregate root reference another root?

I'm a little bit confused. I just watched Julie Lerman's Pluralsight video on DDD and here's the confusion I have: Having a simple online store example with: Purchase Orders with Items for Suppliers, ...
Ish Thomas's user avatar
  • 2,350
23 votes
3 answers
8k views

How do read-only database views fit into the repository pattern?

Example: Your database has a SQL view named "CustomerOrdersOnHold". This view returns a filtered mix of specific customer and order data fields. You need to fetch data from this view in your ...
300 baud's user avatar
  • 1,672
21 votes
5 answers
12k views

DDD: Entity identity before being persisted

In Domain Driven Design, one of the defining characteristic of an Entity is that it has an identity. Problem: I am not able to provide a unique identity to Entities on instance creation. This ...
Dave New's user avatar
  • 39.4k
18 votes
1 answer
4k views

Update an entity inside an aggregate

I was reading a similar question on SO: How update an entity inside Aggregate, but I'm still not sure how a user interface should interact with entities inside an aggregate. Let's say I have a User, ...
BenMorel's user avatar
  • 35.5k
18 votes
1 answer
7k views

Dealing with nested aggregates in DDD

I'm just getting started in DDD, and I'm having some trouble figuring out how to accommodate the relational nature of my data. I have what I believe would be considered my aggregate root, but the ...
Josh Anderson's user avatar
16 votes
6 answers
7k views

DDD - Modifications of child objects within aggregate

I am having some difficulty working out the best way to handle a fairly complex scenario. I've seen quite a few similar questions, but none addressed this scenario to my satisfaction. An Order (...
Cork's user avatar
  • 722
16 votes
3 answers
5k views

DDD: aggregate root question

Let's say i got 2 entities - Foo and Bar. Foo is an aggregate root and contains Bar. As far as i understand, it should look like this: public class Foo{ private readonly Bar Bar; } I want to ...
Arnis Lapsa's user avatar
  • 46.7k
15 votes
2 answers
5k views

Why are repositories only used for aggregates in Domain-Driven Design?

In DDD, repositories are used to perform serialization and de-serialization of aggregates, e.g. by reading and writing to a database. That way, aggregates can contain purer business logic, and won't ...
Hannes Petri's user avatar
14 votes
2 answers
5k views

How should I enforce relationships and constraints between aggregate roots?

I have a couple questions regarding the relationship between references between two aggregate roots in a DDD model. Refer to the typical Customer/Order model diagrammed below. First, should ...
Eric Anastas's user avatar
13 votes
3 answers
7k views

DDD navigation to entities inside aggregate root via composite identity

I have an aggregate root Products which contains a list of entities Selection, which in turn contains a list of entities called Features. The aggregate root Product has an identity of just name The ...
morleyc's user avatar
  • 2,299
13 votes
2 answers
4k views

Aggregate Root support in Entity Framework

How can we tell Entity Framework about Aggregates? when saving an aggregate, save entities within the aggregate when deleting an aggregate, delete entities within the aggregate raise a concurrency ...
Brian Low's user avatar
  • 11.7k
13 votes
2 answers
2k views

DDD: solution for references to a non aggregate root

I have two aggregate roots and two non aggregate root entities: I know, that the relation D -> B breaks DDD principle. I heard, that in the most cases the solution is to make the referenced ...
frol's user avatar
  • 185
12 votes
4 answers
6k views

DDD - How to design associations between different bounded contexts

I have setup a domain project which is being populated with an ORM. The domain contains of different aggregates each with its own root object. My question is how properties that cross the aggregate ...
Laoujin's user avatar
  • 10.1k
12 votes
4 answers
3k views

Should lookup values be modeled as aggregate roots?

As part of my domain model, lets say I have a WorkItem object. The WorkItem object has several relationships to lookup values such as: WorkItemType: UserStory Bug Enhancement Priority: High ...
Landon Poch's user avatar
12 votes
2 answers
9k views

one repository for each root aggregate entity in domain driven design

If you follow the repository pattern they... say to create a repository for each root aggregate entity. That means when I have this model: customer has orders order has products product has supplier ...
Elisabeth's user avatar
  • 20.9k
12 votes
2 answers
2k views

Bounded context implementation and design

Let's say I have two bounded contexts, the Shipping Context and the Billing Context. Each of these contexts need to know about the customer. At a data level, the customer is represented by a ...
Dave New's user avatar
  • 39.4k
12 votes
1 answer
11k views

Aggregates in CQRS

What are aggregates and how are they used in CQRS (Command-Query-Responsibility-Segregation) and ES (Event-Sourcing)? I'm new to this kind of architecture, and I'd be really happy if someone could ...
shmuli's user avatar
  • 5,132
11 votes
3 answers
12k views

Aggregate root with Entity Framework using Domain Driven Design

I am building an application using Domain Driven Design that is using Entity Framework. My goal is to allow my domain models (that get persisted with EF) contain some logic within them. Out of the ...
Matthew's user avatar
  • 25.3k
11 votes
3 answers
3k views

DDD: refer to an entity inside an aggregate root by its identity

I'm stuck on finding the proper way to refer to entities located inside an aggregate root, when we only got their identities coming from URL parameters. I asked a previous question which ended up ...
BenMorel's user avatar
  • 35.5k
10 votes
1 answer
10k views

Entity vs Aggregate vs Aggregate Root

I am struggling to identify Domain objects. Problem: A company has one or multiple Sites A Site has main and multiple contacts Thus, a company has one or many contacts. These contacts are ...
MJK's user avatar
  • 3,454
10 votes
1 answer
3k views

DDD: can a Repository return entities inside an aggregate?

I have a City aggregate, having a list of PointOfInterest entities. This latter entity lies logically inside the City aggregate for reasons that won't be explained here. No entity holds a link to ...
BenMorel's user avatar
  • 35.5k
9 votes
2 answers
5k views

DDD - Enforce invariants with small aggregate roots

I'm having my first attempt at DDD and I'm running into a problem with aggregate design. My application contains 3 Entities; Graph, Node, Link. Each of these entities has a name property which can ...
tonyj444's user avatar
  • 383
9 votes
3 answers
2k views

Aggregate roots. How far does the rabbit hole go

I'm trying to use the Repository pattern for my current project and i'm currently in the process of trying to model the domain and find the aggregate roots. I've read of the 'Cascading Delete' rule ...
Mathew's user avatar
  • 203
9 votes
1 answer
3k views

Domain driven design child entities change tracking

I'm having some difficulty figuring out how the Aggregate Root will track changes on child entities. Let say I have an aggregate: Order (root) OrderLineItem With the Order class being the ...
Patrick87's user avatar
  • 247
9 votes
4 answers
2k views

DDD - Enforcing rules which need to know about multiple aggregate roots

I'm new to DDD, and currently looking at rebuilding an existing application by starting with a bit of a proof of concept while I'm still finding my way with DDD. My questions here only concern a small ...
Stu Ratcliffe's user avatar
9 votes
3 answers
2k views

DDD: Getting aggregate roots for other aggregates

I've been studying DDD for the past 2 weeks, and one of the things that really stuck out to me was how aggregate roots can contain other aggregate roots. Aggregate roots are retrieved from the ...
Ed.'s user avatar
  • 91
8 votes
2 answers
1k views

Aggregate for one entity

In Domain-driven design if I want to use a repository I need to have an aggregate for it - as I understand. So I have a User, that has id, login, email, and password. A user is a domain Entity with ...
Radek's user avatar
  • 669
8 votes
2 answers
2k views

Multiple Aggregates Root INSTANCES per transaction

In DDD the Aggregate should represent the transactional boundary. A transaction that requires the involvement of more than one aggregate is often a sign that either the model should be refined, or the ...
Joshscorp's user avatar
  • 1,832
8 votes
1 answer
3k views

How to implement checkout in a DDD-based application?

First of all let's say I have two separated aggregates Basket and Order in an e-commerece website. Basket aggregate has two entities Basket(which is the aggregate root) and BaskItem defined as ...
Simple Code's user avatar
  • 2,474
8 votes
3 answers
1k views

CQRS Repository/event publisher

I am using CqrsLite for a CQRS-style project. The Save method of the concrete Repository implementation looks like so (with irrelevant lines omitted). public void Save<T>(T aggregate, int? ...
Matt's user avatar
  • 1,678
8 votes
2 answers
627 views

How to model sort order for many-to-one across two aggreagate roots

Take the domain proposed in Effective Aggregate Design of a Product which has multiple Releases. In this article, Vaughn arrives at the conclusion that both the Product and Release should each be ...
George Mauer's user avatar
8 votes
2 answers
870 views

DDD functional way: Why is it better to decouple state from the behavior when applying DDD with functional language?

I've read several articles (also the book Functional domain modeling) where they propose to decouple state of the domain object from the behavior, but I cannot understand advantage of such approach ...
Teimuraz's user avatar
  • 9,115
8 votes
2 answers
5k views

Domain Driven Design - How to handle updates for parts of your aggregrate roots

BACKGROUND: I have a Person domain object. It is an aggregate root. I have included a portion of the class below. I am exposing methods to perform the objects behaviors. For instance, to add ...
RDotLee's user avatar
  • 1,083
8 votes
1 answer
498 views

Custom Field Design with C# and RavenDB

I'm facing a key design question related to how to attach custom fields to entities in my system. The entities are represented in C# and persisted in RavenDB. We are roughly following tenants of ...
Eric Farr's user avatar
  • 2,693
7 votes
3 answers
3k views

DDD - How Can I Avoid Crossing Aggregate Boundaries Here?

We're working on a new project (re-writing existing app), and I'm running into problems with my domain model / repository design. Here is a (simplified) version of two key portions in our domain ...
RPM1984's user avatar
  • 72.6k
7 votes
1 answer
3k views

DDD Customer, Contacts, and Addresses (aggregate root)

I'm building an application that manages most of the LOB stuff at my company. I'm trying to wrap my head around DDD... starting with customer management. Many examples are very, very simple in regards ...
Chris Klepeis's user avatar
7 votes
4 answers
2k views

When to update audit fields? DDD

I have a Meeting Object: Meeting{id, name, time, CreatedBy, UpdatedBy} and a MeetingAssignee{id, MeetingID, EmployeeId, CreatedBy, UpdatedBy) Meeting, as Aggregate root, has a method ...
user676767's user avatar
7 votes
3 answers
4k views

What is an Aggregate Root?

No, it is not a duplication question. I have red many sources on the subject, but still I feel like I don't fully understand it. This is the information I have so far (from multiple sources, be it ...
Max's user avatar
  • 1,095
7 votes
2 answers
5k views

Is Aggregate Root with Deep Hierarchy appropriate in DDD?

I have a system where a user answers question in a form. I have objects representing this model but I am not quite sure how to organize these objects in terms of DDD. Form (has its own list of) ...
ddv's user avatar
  • 135
7 votes
1 answer
5k views

The role of Aggregate roots in a REST API (DDD)

I'm creating a new REST/hypermedia API for an on line auction service. I'm using this as an exercise to better understand Domain Driven Design approach as for the most part it seems like a good ...
apostrophedottilde's user avatar
7 votes
1 answer
10k views

Aggregate roots and repository in DDD

I just started on DDD and encounter the term aggregate roots. My current understanding is that this is kind of a parent entity that hold reference to other complementary entity. Example : aggregate ...
hollycrab's user avatar
  • 315
7 votes
1 answer
1k views

In Domain Driven Design, may a transaction modify more than one aggregate?

In "Domain Driven Design: Tackling Complexity in the Heart of Software", Evans defines An Aggregate is a cluster of associated objects that we treat as a unit for the purpose of data changes. ...
meriton's user avatar
  • 69.4k
7 votes
3 answers
5k views

DDD: how to properly implement with JPA/Hibernate entities relation?

If we follow DDD principles, one aggregate root should have only references (by id) to another aggregate root(s). Example: // Product Aggregate root class Product { // References to categories ...
Teimuraz's user avatar
  • 9,115
7 votes
1 answer
3k views

DDD: Aggregate Root accessed by another aggregate root

I am currently developing a DDD application and am confused about how to handle a scenario where it seems as if I have to access an aggregate root from another aggregate root. Here is an overview of ...
user1790300's user avatar
  • 2,033
7 votes
2 answers
3k views

Is it OK to create huge events in Event Sourcing?

We are using event sourcing and construct aggregates from stream of events. I have 2 aggregates - A1 and A2. A1 is used as a template in order to create A2. The size of A1 can be pretty big. The ...
Nastya Kholodova's user avatar
7 votes
2 answers
2k views

How to handle paging of sub entities with the repository pattern?

I'm learning domain driven design. I am currently trying to write a simply application in C# designing it using DDD. This application has an aggregate root A which can contain 0..n sub entities B. ...
David Nordvall's user avatar

1
2 3 4 5
10