Skip to content
Ameen Abozaid
Planned lessonJNR-030-L07

Demo: mapping Order and OrderLine as an aggregate

  • Lesson 7 of 8
  • Junior
On This Lesson 3 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

map the order aggregate; prepares JNR-030-LAB1.

Draft outline details

Step by step

  1. Create Order (id, customer, status, createdAt) and OrderLine (id, product, quantity, unitPrice).
  2. Add @ManyToOne(LAZY) from Order to Customer and from OrderLine to Product.
  3. Add lines with cascade = ALL, orphanRemoval = true and the addLine/removeLine helpers.
  4. Planned mistake: add a line to the list without setting line.setOrder(this); show the null foreign key error and fix it with the helper.
  5. Save an order and read the SQL log: one order insert, then one insert per line.

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.