Adding models
In this section, we will now write code for our application, and the first thing we will create is models. In simple terms, models are the object of our application; the models will serve as our entities and will define our tables in the database.
Once we create models and run the application, this will also generate tables in our database automatically with the help of annotations, which will also be discussed throughout this example.
Creating models with DTOs and Lombok
We will first show you how to write models using Lombok and data transfer objects (DTOs). First, we will discuss DTOs.
DTOs
DTOs are responsible for carrying data between processes to reduce the number of method calls. DTOs are plain old Java objects (POJOs) that commonly consist of data accessors.
DTOs are very useful for creating representations of our entities to have views for clients without affecting the pattern and design. Let’s have an example use case for DTOs. You can...