Introduction to Spring Data JPA, Part 3: Unidirectional One to Many Relations

We will look into unidirectional one-to-many relations. We will use Cascade Types, a constructor-based dependency injection by removing the @Autowired annotation. We will accomplish this with a small implementation where we will handle the DELETE operation, understand  @PathVariable annotation, use Orphan removal, and the @Transaction  annotation.

Let us consider an organization. Here there will be many employees, each taking up different tasks. Let us call the employees users and classify their tasks into roles they play. Some may be performing managerial task, so we'll give them the role MANAGER. Some may be performing system administration tasks, so we'll give them the role ADMIN.