How to do it...

  1. 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;        }
  1. Create com.packt.boot_db_demo.PersonMapper to map the data from the database into our model class, Person:
        @Mapper        public interface PersonMapper {        }
  1. 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();
  1. Another method to get the details of a single person identified by ID is as follows:
 @Select("SELECT ...

Get Java 11 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.