In this video, we'll be looking at the Jakarta Persistent Specification. The Jakarta Persistent Specification, also known as Jakarta Persistent API or JPA, consists of multiple APIs facilitating data management in relational databases. It offers developers a powerful solution for mapping Java classes to database tables, enabling easy creation, reading, updating, and deletion of data. This video will provide a brief overview and you'll encourage to look at the full specification documentation for each of the APIs. Jakarta Persistence is included in the Jakarta EE platform and Jakarta EE web profile. If using the full platform or web profile, there is no need to add Jakarta Persistence as a separate dependency. However, if adding individual specifications, the Jakarta Persistence API artifact ID should be added as a maven dependency. Database tables can be mapped directly to plain old Java objects, otherwise known as Pojos, that contain special annotations for Jakarta Persistence. These classes are called Entity classes. A single table typically maps to a single Entity class and the columns of a table map to the field declared within the Entity class. However, in advanced cases, it is possible to map entities in different ways to make the data more flexible. There are a large number of annotations that can be used to customize entity classes in order to achieve the database mapping solution to suit the needs of the task. An entity class should contain the ATT Entity annotation, as well as an ATT table annotation, which specifies the name of the associated database table using its name attribute. Each column of the table then contains a corresponding field declaration in the class and an ATT column annotation with an optional name attribute to designate the name of the associated database column. Relational databases are built around the idea of breaking down data types into their simplest form possible and creating tables to hold the data. Since tables correlate to simple form, also known as a first normal form, oftentimes it takes more than one table to store the data associated along with corresponding attribute data. Relating tables to each other is also known as joining the tables, usually by providing a column to hold the keys for the related tables. Entity classes can also provide relationships to other entities in a similar manner. There are a number of ways to relate Jakarta persistence entity classes to each other, typically using one of the following relationship annotations. At 1 to 1, at 1 to many, at many to 1, or at many to many. Applying these annotations on entity class fields enables one to join entity classes to each other and thereby obtain access to related data via the use of excesser methods. Typically, when using these annotations, attributes are used to specify the database columns which are used to store the keys for the related table. It's important to note that one may specify a fetch type with the entity relationship annotations which dictates how the data from related tables is retrieved. Fetch type options are eager and lazy. Jakarta persistence facilitates primary key creation for database tables through generators, allowing entity classes to auto generate values. An entity manager must be obtained from within an application resource and it is responsible for executing queries and returning data. The persistence context contains configuration for a persistence unit. After a persistence unit has been configured, an entity manager can be injected into a resource via the at persistence context annotation. After an entity manager has been injected into a resource, it can be called upon to create, return, update and delete database records working directly with the entity classes. Jakarta persistence also specifies an API that can be used to obtain metadata regarding entities that are managed by a persistence unit. For each entity class that belongs to a particular package, a meta model class is automatically created by Jakarta persistence which has the same name as the entity class along with a trailing underscore. The meta model class contains attributes that correspond to the fields of the entity class. The most common operations used in applications that persist data are create, read, update and delete or crud operations. Crud operations are commonly associated with relational databases but can be applied to any persistence mechanisms. Writing code for these operations is usually repetitive work consisting mostly of boilerplate code. As entity classes map to database tables, it can be used to create new records. Creating a record is as easy as instantiating a new entity class, populating it with data and persisting it by calling upon the entity manager, create method and passing the new object. Jakarta persistence enables the ability to retrieve data from entity classes. The basic semantics of a query consist of the select clause, the from clause and an optional where clause. Jakarta persistence offers a few different ways to construct queries, those being Jakarta persistence query language, criteria API and named queries. Using Jakarta persistence query language, one can develop SQL like queries to obtain data from the database through the use of entity classes. The criteria query API enables developers to use a criteria builder to construct queries, compound selections, expressions, predicates and orderings. Lastly, named queries allow one to associate a static Jakarta persistence query language query to a name and then call upon that name using an entity manager to execute. Oftentimes queries need to return distinct fields rather than entire objects. When the fields are being returned from a query do not correspond to the object relational mapping metadata, SQL results set mapping must be used. This solution allows explicit field mapping to be provided to enable the persistence provider to map the results correctly. Entity managers make it easy to perform updates on an entity to modify an entity, simply set the new values using the entity class successor methods and then pass the updated entity to the entity manager merge method. To remove an entity associated to a record from a database pass the entity to the entity manager remove method. Jakarta persistence provides the capability to generate database schema objects when an application is deployed. It can also be configured to load data into objects and remove the schema objects once the application is destroyed. This may be useful if an application is being used for a demo and the database should be recreated with each new deployment to the container. A stored procedure is a code construct that is stored within a relational database when in-vote the stored procedure will execute and can optionally return an outcome. Jakarta persistence provides the stored procedure query interface to enable the invocation of database stores procedures. In conclusion Jakarta persistence is a widely used specification which is required for accessing relational data within a Jakarta EE application. The use of Jakarta persistence can also be quite simplistic depending upon the requirements of the application. Jakarta persistence makes it easy to work with Java objects to create, read and update and delete data from a relational database using pure Java. For more information about the Jakarta persistence specification please visit our website. www. Jakarta persistence.com