In this opportunity I will explore a little deeper Spring Data and JPA.
We will replicate the scenario of the previous tutorial (Spring Boot CRUD + MVC + JPA + H2) Adding user roles with relationships from many to many (1: *) and one-to-one configuration (1:1).
See in the following image the entity model relationship for the exercise of this tutorial.
You will learn new things from Spring Framework, JPA and Thymeleaf.
Spring Framework: Captures the ContextRefreshedEvent that allows you to execute action once the application is successfully executed. If you know JQuery or JS would be like capturing in event onload or $(document).ready(); Help you assign what your application needs to work, in this case I need you to list the existing roles.
JPA: Learn how to create one-to-one relationships (@oneToOne) and many to many (@ManyToMany) with a transaction table.
Thymeleaf: Uses little by little more form elements with Thymeleaf. In this case add Checkbox using a Boolean value, also fields of type Radio, Select and Date.
In the following video I will show a CRUD example again, but adding the described in the previous section. Observe the description of the video directly on YouTube where you see in what specific time I talk about each topic.
Also I will leave the link to the GitHub repository if you want to download my code to test or compare
GitHub repository: GitHub
Spring Boot Introduction:
- Spring Boot – 01 – What is it? And how do you eat?
- Spring Boot + MVC Part 1 | Using JSP?
- Spring Boot + MVC Part 2 | Using Thymeleaf
- Spring Boot CRUD + MVC + JPA + H2 Part 1
- Spring Boot CRUD + MVC + JPA relations 1:1 and *:* (current)