Skip to content
Ameen Abozaid
Planned lessonJNR-030-L04

Many-to-many and join entities

  • Lesson 4 of 8
  • Junior
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

  • @ManyToMany uses 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 (OrderLine links Order and Product with quantity and price).
  • Each side then has a plain @OneToMany to 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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.