Unidirectional by default
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
keep relationships as simple as possible.
Planned topics
- A relationship defined on one side only (unidirectional) is simpler and safer.
- Add the second side only when a real use case needs navigation.
- Bidirectional mappings need synchronization code and cause serialization loops (infinite JSON) if returned.
OrderLine->Productis unidirectional: a line knows its product, a product does not list its lines.- To find "all lines of a product", use a query instead.
Draft outline details
Demonstration
a diagram with arrows only in one direction: OrderLine → Product, Order → OrderLine (with mappedBy back-reference).
Check your understanding
Does Product need a List<OrderLine>?
Show answer
No; use a repository query when needed.
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.