0

So we are trying to implement DDD and CQRS (without event sourcing). I am need of clarity about the implementation details (Spring + JPA).

DDD with multiple small aggregate roots require @Entity classes with ID for maintaining relationships than having explicit relationships. As per Effective Aggregate Design by vaughn vernon

My questions is If we want to implement a simple CQRS do we need to duplicate all my JPA Entities for both Read and Write.?

If going with this.

  1. Separate Read/Write Controllers
  2. Inject QueryService and CommandService into respective controllers so as to have clear hand off in project structure
  3. In 'Domain' folder I maintain my Aggregate Entities (Also JPA Lazy loading) and Aggregate Root Repositories.
  4. In my Infrastructure I need to maintain Almost same Entities (JPA Eager loading?) Or Should I just write plain simple SQL queries using SpringJdbcTemplate
  5. Have my QueryService inside my Infrastructure code.
  6. Have my CommandService inside my Infrastructure code where I will call domain repositories and domain services (as in here ddd by example) and call Audit tables (simple events)

(without event sourcing because we cannot support that technology and we are short on time and new to DDD and CQRS)

My question on Item 4) and if writing in queries vs alternate set of JPA entities. If queries what JPA technologies are famous libraries will help to fetch aggregate root's child entities easily? I know there is a trade of but need your thoughts a bit of decision points.

  • we are short on time and new to DDD and CQRS it has all the recipes for the disaster. Anyways, the title of the question and the question If queries what JPA technologies are famous libraries will help to fetch aggregate root's child entities easily? are very different questions. Can you state clearly what's your question? – Laiv Apr 29 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.