Pro Cloud Native Java EE Apps by 2022

Pro Cloud Native Java EE Apps by 2022

Author:2022
Language: eng
Format: epub


CHAPTER 5

Persistence with Jakarta

EE Persistence

Every application needs to store data at some point during its execution to a durable

data store. The data store could be as simple as a flat file and as complex as a full-fledged database management system. The data store acts as the single source of truth for the

application. For instance, the bank balance of your account with your bank is stored

in some form of data store. This single data is the only source of truth for the bank in identifying how much money they are keeping for you.

Irrespective of the language and platform an application is written in, the process of storing application data into a durable data store generally spans three broad categories, namely, data modelling, data persistence, and data retrieval. In Enterprise Java, the

Jakarta Persistence API is a fully featured specification that allows you to realize these three broad application data persistence categories through the use of annotations and intuitive interfaces.

This chapter is about persisting data to a relational database using the Jakarta

Persistence API or JPA. The goal isn’t to teach you everything about JPA, but rather

the essentials of what you need to get very common application data persistence

requirements fulfilled. For a much more comprehensive overview and reference for JPA,

please take a look at the specification1 document. The chapter is split into the three main categories of data modelling, data persistence, and data retrieval.

All the examples in this chapter use the Postgres database as the underlying

database. However, the same principles should apply to all database engines out there as long as you use the JPA constructs. By the end of this chapter, you should be comfortable in using the JPA specification to persist your application data to a relational database.

1 Jakarta Persistence 3.1 Specification

139

© Luqman Saeed and Ghazy Abdallah 2022

L. Saeed and G. Abdallah, Pro Cloud Native Java EE Apps, https://doi.org/10.1007/978-1-4842-8900-6_5



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.