Summary
This chapter covered how to access data in a database via Jakarta Persistence, the standard object-relational mapping API of Jakarta EE.
In this chapter, we covered the following topics:
- How to mark a Java class as a Jakarta Persistence entity by decorating it with the
@Entity
annotation, and how to map it to a database table via the@Table
annotation. We also covered how to map entity fields to database columns via the@
Column
annotation. - Using the
jakarta.persistence.EntityManager
interface to find, persist, and update Jakarta Persistence entities. - How to define unidirectional and bidirectional one-to-one, one-to-many, and many-to-many relationships between Jakarta Persistence entities.
- How to use composite primary keys by developing custom primary key classes.
- How to retrieve entities from a database by using the Jakarta Persistence Query Language (JPQL) and the Criteria API.
- Bean Validation, which allows us to easily validate input by simply...