Cascade Types and orphanRemoval
Learn Cascade Types and orphanRemoval (Spring Data JPA, Spring Boot) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
The Problem Cascade Solves An Order has many OrderLine s. Without cascading you must save the order, then loop and save every line yourself, and delete the lines before deleting the order. Cascade tells JPA: "when I do this operation to the parent, do it to the children too."
More lessons in Spring Data JPA
- ORM, JPA and Hibernate
- Spring Data JPA
- Entity Mapping: @Entity, @Table, @Id, @Column
- Derived Query Methods - Fetch by Single & Multiple Fields
- JPQL and @Modifying Queries
- Native Query with @Query
- Mapping - Real-World Scenarios
- Mapping - One-to-One & One-to-Many
- Mapping - Many-to-One & Many-to-Many
- Join Queries & DTO Projection
- JPA Advanced - Auditing, Locking & Specifications
- Mini Project: Student Repository with Spring Data JPA