JPA (Jakarta Persistence API), formerly known as the Java Persistence API, is the standard way to work with relational databases in Java. Instead of writing SQL statements and mapping result sets by hand, you work directly with Java objects, and JPA takes care of storing and loading them for you.
JPA itself is only a specification. To use it, you need an implementation, and the most popular one is Hibernate. Other implementations include EclipseLink and Apache OpenJPA. If you use Spring Boot or Spring Data JPA, you are already using JPA with Hibernate under the hood.
This JPA tutorial teaches JPA in depth with Hibernate as the implementation, in 31 step-by-step tutorials.
What you will learn:
- JPA fundamentals: the JPA architecture, how to set up JPA with Hibernate, and the entity life cycle.
- Entities and mapping: how to create entities, generate primary keys, and map associations and inheritance hierarchies.
- Working with data: how to store, retrieve, update, and delete entities with the EntityManager.
- Interview preparation: the most common JPA interview questions, including the difference between JPA and Hibernate.
How to use this tutorial: Watch the short video below to understand what JPA is, then work through the sections in order. Once you are comfortable with JPA, continue with the complete Hibernate Tutorial.
What is JPA? (YouTube Video)
1. JPA Getting Started
Start here. Learn what JPA is, how it is designed, and how to set it up with Hibernate.
2. JPA Entity Creation
Learn how to define entities, generate primary keys, and map special field types.
3. JPA/Hibernate Association Mapping
Map relationships between entities in one or both directions.
4. Inheritance Mapping
Map a hierarchy of Java classes to database tables using the four JPA inheritance strategies.
5. JPA Operations (CRUD)
Store, retrieve, update, and delete entity objects with the EntityManager.
6. JPA Core Interfaces
The three interfaces you will use in every JPA application.
7. JPA Interview Preparation
Get ready for technical interviews with the most commonly asked JPA questions.
Great! Thanks for sharing your examples.
ReplyDeletevery Useful
ReplyDelete