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
If going with this.
- Separate Read/Write Controllers
CommandServiceinto respective controllers so as to have clear hand off in project structure
- In 'Domain' folder I maintain my
Aggregate Entities(Also JPA
Lazy loading) and
Aggregate Root Repositories.
- In my
InfrastructureI need to maintain Almost same
Entities(JPA Eager loading?) Or Should I just write plain simple SQL queries using
- Have my
- Have my
Infrastructurecode 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.