Repositories and domain services
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
place persistence and cross-aggregate logic correctly.
Planned topics
- One repository per aggregate root, with collection-like methods:
findById,save. - The repository interface lives in the domain; JPA implements it (MID-059).
- A domain service holds domain logic that fits no single aggregate, such as pricing across order and discount rules.
- Do not confuse it with an application service, which orchestrates use cases and transactions.
- No repository for inner objects like
OrderLine.
Draft outline details
Demonstration
interface OrderRepository { Optional<Order> findById(OrderId id); void save(Order o); }
Check your understanding
Is there a repository for OrderLine?
Show answer
No, only for the aggregate root.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.