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

Somasundaram Sekar

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 within the aggregate repository, is that a OK solution or anything better available?

To given an example: Customer is the aggregate root and entities are like Demographics, Identification, AssetSummary etc. where each entity can benefit from having their own repository interfaces. What is the best way without violating DDD much?

Oliver Drotbohm

…, but when embracing Spring Data JPA, we can leverage the benefits only when we declare interface per entity…

That's wrong and I would like to learn where you get this impression from (feel free to comment). Spring Data repositories are expecting the exactly same approach to your domain model design: you identify aggregates in your domain model and only create repository interfaces for exactly those.

I'd argue that all you need to do is applying the DDD concept to your domain model. Simply don't declare repository interfaces for entities that are not an aggregate root. In fact, if you declared those, you basically break the concept of an aggregate, as the actual root cannot control business constraints anymore as the other entities can be manipulated through the repository interface defined for them, i.e. without using the aggregate root.

Find an example of this applied correctly in this Spring Data example. In it, Order is an aggregate root, LineItem is just an ordinary entity. The same applies to Customer (root) and Address (ordinary entity). Repository interfaces only exist for the aggregate roots.

In fact, that particular relationship is the fundamental principle that makes modules like Spring Data REST working in the first place. It only exposes HTTP resources for aggregate roots, embeds ordinary entities within the representations created and creates links to other aggregates.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Domain driven design repository implementation in infrastructure layer

From Dev

Domain Driven Design - Domain or Security

From Dev

Where is the call to persistence in the domain driven design

From Dev

Access Control in Domain Driven Design

From Dev

Implementing Domain Driven Design Book Confusion

From Dev

Domain Driven Design Bounded Context Domain Objects

From Dev

Domain Driven Design and batch processing

From Dev

Domain-Driven-Design Entities and Value Objects

From Dev

Implementing Domain Driven Design Cost

From Dev

Domain Driven Design - CQRS + ES usage

From Dev

Layers in Domain Driven Design

From Dev

Populating Domain objects with data in a Domain Driven Design architecture

From Dev

Domain driven design: How to deal with complex models with a lot of data fields?

From Dev

Domain Driven Design in Node.js Application

From Dev

Domain Driven Design Auto Incremented Entity Key

From Dev

Implementing Paging and Sorting with Domain Driven Design

From Dev

Domain Driven Design: Can Infrastructure or Repositories use Domain objects?

From Dev

Proper way to get aggregates in Domain Driven Design

From Dev

Implementing Domain-Driven Design and Transactions

From Dev

Domain Driven Design: infrastructure concern or domain concern?

From Dev

Domain Driven Design (DDD) and database generated reports

From Dev

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

From Dev

Fetching associated aggregates in Domain driven Design

From Dev

Domain Driven Design - where should we put repositories?

From Dev

Implementing Domain Driven Design Cost

From Dev

Data driven design, referencing the data

From Dev

Domain Driven Design: Can Infrastructure or Repositories use Domain objects?

From Dev

Domain Driven Design: infrastructure concern or domain concern?

From Dev

Domain Driven Design. Entity type design

Related Related

  1. 1

    Domain driven design repository implementation in infrastructure layer

  2. 2

    Domain Driven Design - Domain or Security

  3. 3

    Where is the call to persistence in the domain driven design

  4. 4

    Access Control in Domain Driven Design

  5. 5

    Implementing Domain Driven Design Book Confusion

  6. 6

    Domain Driven Design Bounded Context Domain Objects

  7. 7

    Domain Driven Design and batch processing

  8. 8

    Domain-Driven-Design Entities and Value Objects

  9. 9

    Implementing Domain Driven Design Cost

  10. 10

    Domain Driven Design - CQRS + ES usage

  11. 11

    Layers in Domain Driven Design

  12. 12

    Populating Domain objects with data in a Domain Driven Design architecture

  13. 13

    Domain driven design: How to deal with complex models with a lot of data fields?

  14. 14

    Domain Driven Design in Node.js Application

  15. 15

    Domain Driven Design Auto Incremented Entity Key

  16. 16

    Implementing Paging and Sorting with Domain Driven Design

  17. 17

    Domain Driven Design: Can Infrastructure or Repositories use Domain objects?

  18. 18

    Proper way to get aggregates in Domain Driven Design

  19. 19

    Implementing Domain-Driven Design and Transactions

  20. 20

    Domain Driven Design: infrastructure concern or domain concern?

  21. 21

    Domain Driven Design (DDD) and database generated reports

  22. 22

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

  23. 23

    Fetching associated aggregates in Domain driven Design

  24. 24

    Domain Driven Design - where should we put repositories?

  25. 25

    Implementing Domain Driven Design Cost

  26. 26

    Data driven design, referencing the data

  27. 27

    Domain Driven Design: Can Infrastructure or Repositories use Domain objects?

  28. 28

    Domain Driven Design: infrastructure concern or domain concern?

  29. 29

    Domain Driven Design. Entity type design

HotTag

Archive