Java Persistence API (JPA) 2.1

Learn how to map Java objects to a relational database in your Java SE and Java EE applications.
Course info
Rating
(425)
Level
Intermediate
Updated
May 19, 2014
Duration
3h 43m
Table of contents
Course Overview
Introduction
Understanding Java Persistence API
Managing Elementary Entities With JPA
Relationships and Inheritance
Querying Entities
Entity Lifecycle, Callbacks, and Listeners
JPA 2.1 Within Java EE 7
Description
Course info
Rating
(425)
Level
Intermediate
Updated
May 19, 2014
Duration
3h 43m
Description

Applications are made up of business logic, interaction with other systems, user interfaces, and data. Most data manipulated by our Java applications have to be stored in databases, retrieved, and analyzed. In this course, you will learn the principle of object-relational mapping (ORM) and how to use Java Persistence API (JPA) to map your Java objects into relational databases.

About the author
About the author

Antonio is a senior software architect living in Paris.

More from the author
Microservices: The Big Picture
Beginner
1h 45m
16 Apr 2018
Java EE: Getting Started
Beginner
5h 0m
22 Jun 2017
Java EE 7 Fundamentals
Beginner
5h 25m
12 Aug 2016
More courses by Antonio Goncalves
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone. My name is Antonio Goncalves. Welcome to my course Java Persistence API 2. 1. I am an independent developer, a book author, and a recognized Java Champion. I also like to speak at international conferences about my favorite topic, Java EE. So, if you know Java EE or Spring and you've been asked to map objects to a relational database and query them, this course is for you. In this course, you will learn Java Persistence API, one of the most used Java EE specifications. Some of the major topics that I will cover include understanding JPA and its advantages over pure JDBC, managing entities with CRUD operations. That's one of the beauties with JPA, a single line of code, and you can insert, find, update, or delete an object. Mapping simple entities, as well as relationships or inheritance. Querying entities with the powerful Java Persistence query language. I will also cover some more advanced features such as entity lifecycle, callbacks, and listeners. Finally, you will put all these pieces together so you can bring JPA to your Java EE or Spring project. By the end of this course, you'll have a very good understanding of the possibilities brought by JPA. Before beginning the course, you should be familiar with the Java programming language, as well as relational databases. This course will guide you through all of the major points covered by JPA. I hope you will join me on this journey to learn object relational mapping with the Java Persistence API 2. 1 course at Pluralsight.

Understanding Java Persistence API
Hi, my name is Antonio Goncalves, and I want to welcome you to this module about Understanding Java Persistence API. I will use the second module to show you what JPA is, what it's not, and in which layer of our applications we can use it. In this module, I will recap what a relational database is and why we use object-relational mapping tools. Then, I will introduce Java Persistence API, tell you what it is, what it does, but also what it's not. JPA comes with annotations to map out objects into a database and a set of APIs to perform CRUD operations, and to query these objects in both Java SE and Java EE.

Managing Elementary Entities With JPA
Hi, my name is Antonio Goncalves, and I want to welcome you to this module about Managing Elementary Entities with JPA. In this module, I will show you the common operations that you can do with the EntityManager API. I'll explain what a persistence unit is and how it is related to the EntityManager. Then, I will show you some basic mapping metadata using annotations, but also the XML equivalent. I'll wrap up this module with a demo explaining how to unit test your entities.

Relationships and Inheritance
Hi, my name is Antonio Goncalves, and I want to welcome you to this fourth module that explains how to map relationships and inheritance between entities in JPA. If entities contain only simple persistence state, object-relational mapping would be trivial, but most entities need to be able to reference other entities, either through relationships or inheritance. In this module, I will explain relationships and inheritance in terms of object-oriented programming and relational databases. As you will see, some of these concepts are easier to map in JPA than others.

Querying Entities
Hi, my name is Antonio Goncalves, and I want to welcome you to this fifth module about Querying Entities with Java Persistence Query Language. Java Persistence API has two sides. The first is the ability to map objects to a relational database, the second is the ability to query these mapped objects. In JPA, the centralized service to manipulate entities is the EntityManager. It provides an API to create, find, remove, and synchronize objects with the database, but it also allows the execution of different sorts of queries using the Java Persistence Query Language, also known as JPQL. JPQL has a very rich syntax, and as you'll see, can be used with dynamic or named queries.

Entity Lifecycle, Callbacks, and Listeners
Hi, my name is Antonio Goncalves, and I want to welcome you to this module about Entity Lifecycle, Callback Annotations, and Entity Listeners. In this module, you will learn that entities have a special lifecycle compared to other Java EE components. Basically, they are managed by the EntityManager or detached. On this lifecycle, we can apply callback annotations to perform some kind of business logic before or after the entity is persisted for example. This is a fantastic way to add business logic to our entities instead of leaving them empty just with attribute getters and setters, but no methods. I'll wrap up this module with entity listeners, which is a way of externalizing common behavior of callback annotations.

JPA 2.1 Within Java EE 7
Hi, my name is Antonio Goncalves, and I want to welcome you to this last module that covers integration between JPA 2. 1 and Java EE 7. In this module, I will give you a very quick overview of Java EE 7 and I will focus on the services given by the Java EE container to Java Persistence API. You will see how JPA is deeply integrated with some specifications such as context and dependency injection, bean validation, transactional components, and external systems such as REST Web Services or Java Messaging Service. I will finish this module with a summary of the course and I will give you some extra pointers for external references.