How to do it...

  1. Let's start with adding the javax.persistence package dependency to the Maven configuration file pom.xml:   
<dependency>    <groupId>javax.persistence</groupId>    <artifactId>javax.persistence-api</artifactId>    <version>2.2</version></dependency>

We don't need any of the JPA implementations yet. This way, we can make sure that our code does not use any framework-specific code and uses only JPA interfaces. 

  1. Create the class Person1:
public class Person1 {    private int age;    private String name;    public Person1(int age, String name){        this.age = age; = name;    }    @Override    public String toString() {        return "Person1{id=" + id + ", age=" + age +                          ", name='" + name + "'}";    }}

We don't add getters, setters, or any other methods; ...

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.