Questions tagged [ddd-repositories]

A Repository is a mechanism for encapsulating storage, retrieval, and search behavior which emulates a collection of objects.

The Repository pattern in Domain Driven Design is an extension of the repository pattern which aims at abstracting data persistence concerns so that it appears that client code is dealing with an in-memory collection but where all calls are resolved out into infrastructure specific persistence commands.

454 questions
584
votes
11 answers

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 an aggregate root is, I keep finding discussions…
Dinah
  • 52,922
  • 30
  • 133
  • 149
158
votes
1 answer

How are Spring Data repositories actually implemented?

I have been working with Spring Data JPA repository in my project for some time and I know the below points: In the repository interfaces, we can add the methods like findByCustomerNameAndPhone() (assuming customerName and phone are fields in the…
Vasu
  • 21,832
  • 11
  • 51
  • 67
47
votes
2 answers

How do Repositories fit with CQRS?

According to Fowler (here), a repository "mediates between the domain and data mapping layers, acting like an in-memory domain object collection." So, for example, in my Courier Service application, when a new run is submitted, my application…
SonOfPirate
  • 5,642
  • 3
  • 41
  • 97
42
votes
4 answers

Repository Pattern: how to Lazy Load? or, Should I split this Aggregate?

I have a domain model that has the concept of an Editor and a Project. An Editor owns a number of Projects, and a Project has not only an Editor owner, but also a number of Editor members. Therefore, an Editor also has a number of "joined"…
42
votes
3 answers

Django and domain driven design

I am confused about Domain Driven Design Approaches. From the sources on net I understood it is way of segregating your Domain Objects and Database Objects but I don't understand the difference between two. For an example lets take the code of…
Anubhav Agarwal
  • 1,982
  • 5
  • 28
  • 40
32
votes
5 answers

Is it ok for entities to access repositories?

I've just started working with DDD, so maybe this is a silly question... Is it ok for an entity to access a repository (via some IRepository interface) to get a value at runtime? For example, I want to enforce a "default" selection for a…
29
votes
2 answers

DDD - How to implement high-performing repositories for searching

I have a question regarding DDD and the repository pattern. Say I have a Customer repository for the Customer aggregate root. The Get & Find methods return the fully populated aggregate, which includes objects like Address, etc. All good. But when…
19
votes
2 answers

Where to define the interfaces for a repository in an layered architecture?

Background I'm trying to create a simple application to really understand the whole stack of DDD+TDD+etc. My goal is to dynamically inject the DAL repository classes at runtime. This keeps my Domain and Application Services layers testable. I…
18
votes
1 answer

Is there a mismatch between Domain-Driven Design repositories and Spring Data ones?

DDD specifies repository per aggregate, but when embracing Spring Data JPA, we can leverage the benefits only when we declare interface per entity. How this impedance mismatch can be resolved? I'm hoping to try out repository interfaces encapsulated…
18
votes
2 answers

DDD repository and factory

In my application a few layers. In this topic will focus on Domain and Infrastructure layers. I have repository interface ClientRepositoryInterface in Domain layer. And I have implementation of this interface ClientRepositoryImpl in Infrastructure…
17
votes
2 answers

Can DTO's have nested DTO's?

I have the following domain model: public class Playlist { public long Id { get; set; } public string Title { get; set; } public virtual ICollection Songs { get; set; } } public class Song { public long Id { get; set; } …
14
votes
2 answers

DDD - Where should third-party API interfaces should be?

If we consider a standard persistence repository, the solution is easy. We put the IStuffRepository in the Domain Layer, and the StuffRepositoryImplementation in the Infrastructure Layer. But what is the good pattern when we want to wrap a…
Normand Bedard
  • 2,625
  • 2
  • 19
  • 22
14
votes
4 answers

Where to call repository.update in DDD?

I have a real scenario that is a perfect Domain Model design. It is a field that has multiple quadrants with different states on every quadrant. So my aggregate root is the field. Now i have one important question: I want to have a persitant ignorat…
LaurinSt
  • 952
  • 11
  • 25
14
votes
2 answers

Adding items to a collection using Entity Framework

I'm trying to follow the DDD Repository pattern with Entity Framework 4. But I'm having problems saving changes to collection properties of my aggregate roots. Consider my classes below. Item is my aggregate root which contains a collection of…
Eric Anastas
  • 21,675
  • 38
  • 142
  • 236
13
votes
4 answers

Where do all "bulk" operations belong in DDD?

In DDD one of the key concepts is Repository, which allows you to retrieve Entities (or Aggregate Roots) and then save them back after they are updated. Let assume that we need to perform some 'bulk' operation with entities, and the number of…
alex
  • 74,215
  • 9
  • 49
  • 57
1
2 3
30 31