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;        this.name = 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 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.