Creating the database schema from our code
Creating a database schema and its corresponding Entities in our application, as seen in the previous recipe, requires a lot of repetitive work. Instead, we can create our Entities and we can generate the database schema automatically. In this recipe, we will use Spring Data JPA to generate the database schema based on the entity model of the application.
Getting ready
For this recipe, you will need the same tools as in the previous recipe, namely a PostgreSQL server that you can run in a Docker container or on your computer.
We will use the same code generated in the previous recipe. If you didn’t complete it, you can find a completed recipe in the book’s GitHub repository https://github.com/PacktPublishing/Spring-Boot-3.0-Cookbook/.
How to do it...
We will use the previous example about football teams and players. Still, in this recipe, instead of using an existing database and creating the mapping entities,...