- Create a model class, com.packt.boot_db_demo.Person, to represent a person. We will make use of Lombok annotations to generate the getters and setters for us:
@Data public class Person{ private Integer id; private String firstName; private String lastName; private String place; }
- Create com.packt.boot_db_demo.PersonMapper to map the data from the database into our model class, Person:
@Mapper public interface PersonMapper { }
- Let's add a method to get all the rows from the table. Note that the next few methods will be written inside the PersonMapper interface:
@Select("SELECT * FROM person") public List<Person> getPersons();
- Another method to get the details of a single person identified by ID is as follows:
@Select("SELECT ...