Skip to content
Ameen Abozaid
Planned lessonJNR-030-L08

Demo: cascade and orphan-removal surprises

  • Lesson 8 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

see what cascades and orphan removal really do; prepares JNR-030-LAB1.

Draft outline details

Step by step

  1. Remove one line from the order's list and commit; the log shows a delete for that line only.
  2. Replace the whole list with order.setLines(newList) and show the orphan-removal error ("collection was no longer referenced") and why to mutate the same collection.
  3. Planned mistake: put CascadeType.ALL on OrderLine.product; delete an order and watch it try to delete a product used elsewhere (constraint error).
  4. Remove the cascade and show the order deletes alone.
  5. Summarize: cascade only parent-to-owned-children.

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.

Type to search levels, phases, modules and lessons.