Mapping - Real-World Scenarios
Learn Mapping - Real-World Scenarios (Spring Data JPA, Spring Boot) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Scenario 1 - One User Has Many Policies and Many Nominees Two one-to-many relationships hanging off the same parent. This is where the individual mappings start combining into something that looks like a real application. Business requirement: save one user's details with multiple policies and multiple nominees. Problem statement: design the REST API to save one user with multiple policies and multiple nominees. Table structure Both children carry user_id . The user carries neither - it holds two collections instead.
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 - One-to-One & One-to-Many
- Mapping - Many-to-One & Many-to-Many
- Cascade Types and orphanRemoval
- Join Queries & DTO Projection
- JPA Advanced - Auditing, Locking & Specifications
- Mini Project: Student Repository with Spring Data JPA