Many-to-many and join entities
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
know when @ManyToMany is enough and when to model the link.
Planned topics
@ManyToManyuses a hidden join table with only the two foreign keys.- It cannot hold extra data (quantity, date, price at the time).
- When the link has data, create an entity for it (
OrderLinelinksOrderandProductwith quantity and price). - Each side then has a plain
@OneToManyto the join entity. - Prefer explicit join entities from the start in real systems.
Draft outline details
Demonstration
a diagram: Order 1 — * OrderLine * — 1 Product, where OrderLine has quantity and unitPrice.
Check your understanding
Where do you store the quantity of a product in an order?
Show answer
In the join entity OrderLine.
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.