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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.