JPA for Beginners

All you need to know to build your persistence layer with JPA
using Hibernate or EclipseLink

Almost all enterprise applications use Hibernate or EclipseLink, the two most popular Java Persistence API (JPA) implementations. That makes the JPA specification by far the most popular approach to persist data in relational databases, like Oracle, MS SQL, PostgreSQL, and MySQL.

So, it's no surprise that experience with JPA is also one of the most in-demand skills in Java development.

But learning to use JPA on your own can be a pain.

One moment, it feels like everything is kind of magically working, only to all fall apart as soon as you make a change or when your application is used by multiple users.

I know this situation. I have been there myself.

When I started to learn about Hibernate as a student intern in 2002, I was on my own. My co-workers were great, but they were already working 70-hour weeks desperately chasing some impossible deadlines. So, I read a few things on the internet and copied entity definitions that worked in other projects. That's what all of us do when we try to learn a new framework, right?

For me, it didn't work that well. I was deeply frustrated instead of being excited about learning to use Hibernate. Instead of making my way along a learning curve, I felt like I was continuously hitting my head against a massive wall. It sometimes took me days to get things working, and I started to wonder if I had what it takes to become a software developer.

But it got better over time. I knew some of the basics and was able to create simple entities. 
At least in most cases ...

Over the next few years, I recognized that most problems were caused by a few critical holes in my understanding of the Hibernate fundamentals. With every little gap that I closed, Hibernate and the later specified JPA standard became easier to understand and more and more fascinating. I often thought: 'how easy would it have been if someone had told me all of this during my first project?'

Learning JPA in a structured way changes everything.

Years later, when working at a different company, I saw my younger co-workers experiencing the same frustration while going through a similar learning process. Using JPA and Hibernate had become easier, but the general problem was still the same. Without a detailed and structured introduction that teaches you all essential basics, it was only a tiny step from a smiling "it's pure magic" to a raging "NOTHING WORKS!!!"
Unfortunately, that hasn't changed since then.

At that point, I decided to share my knowledge in a series of internal, 2-hour workshops. We started defining basic terms and implementing basic entity mappings and extended it until we had a fully-featured persistence layer, like the ones we used in our real applications. But this time, everyone had a clear understanding of how and why it worked.

And that was not the only change that happened during these workshops. My co-workers were no longer frustrated with JPA, they used it with confidence and were fascinated by how easy it was to implement new use cases. And they did this faster and with fewer bugs than before. That got them recognition from their co-workers and enabled them to work on more complex and exciting tasks. Some even told me that their new capabilities were positively mentioned in their yearly performance review.

You don't need to go through the same struggles.

With this online training course, I want to offer you the same experience. We will start with the basic concepts and entity mappings, use JPA's lifecycle model to persist our data in the database and implement our own queries using JPQL. 

After taking this course, you will be well prepared to create your own persistence layer with JPA. Instead of hoping to copy the right code snippet from your co-worker or from an answer on Stack Overflow, you will know how to use the right JPA feature in the best way.

Join now to get a structured, in-depth introduction to JPA so that you can build your persistence layer with confidence.

A great course for learning the basics of JPA

Each lesson has a clear focus on a central aspect of JPA and is presented with helpful examples to deepen one's understanding of the content. I especially liked the description of the persistence context and of the entity lifecycle model.


This is a great course that familiarizes a beginner with the basics of JPA and leads to independent thinking.

Klaus Causemann

Software Developer

Start Using JPA with Confidence!

17 video lectures with example projects and exercises that show you everything you need to know to use the JPA specification with one of its popular implementations in your project.

Get familiar with the concept of object relational mapping and the most important terms.

  • Lecture 1: 
    What is ORM?
  • Lecture 2:
    JPA vs. EclipseLink/Hibernate
  • Lecture 3:
    Introducing the Example Project

Learn how to configure and bootstrap your JPA implementation.

  • Lecture 4:
    Dependencies
  • Lecture 5:
    Configuration & Bootstrapping
  • Lecture 6:
    Logging

Understand JPA's defaults for simple mappings and how to customize them.

  • Lecture 7:
    Basic Entity Mappings
  • Lecture 8: 
    Generate Unique Identifier Values
  • Lecture 9: 
    Customize Your Mappings
  • Lecture 10:
    Mapping Enumerations
  • Lecture 11:
    Mapping Dates and Timestamps

Learn about JPA's lifecycle model and how you can use it to persist, update and remove entities.

  • Lecture 12:
    Working with Entities

Model associations between your entities and define when they will be loaded from the database.

  • Lecture 13:
    One-to-Many & Many-to-One Associations
  • Lecture 14:
    Many-to-Many Associations
  • Lecture 15:
    One-to-One Associations
  • Lecture 16:
    Fetch Types

Use JPA's query language to implement queries based on your domain model.

  • Lecture 17:
    JPQL Queries

Included Bonuses

Get even more out of this courses with these free bonuses.

The "I don't have time" Schedule

I know that excuse all too well. I've used it several times myself.

But let's be honest, your schedule will not change. You will not have any time to improve your career unless you make time for it.

Let's start small and invest 1 hour per week into your future. You can find 1 hour in your schedule, right? Maybe during your commute or between meetings or after you put your kids to bed?

The "I don't have time"-Schedule helps you to use that 1 hour efficiently. It tells you exactly which lectures you need to take each week.

And after a few weeks, you can use JPA in your daily work and proudly add one of the most in-demand skills to your CV.

Video series: Create your 1st Persistence Layer

Let's use everything you learned in the lectures and let's build your 1st persistence layer together.

In this 5-part series, you will watch over my shoulder while we implement the persistence layer of a small application. We will start with a table model, then create a maven build with all the required dependencies, implement the entity mappings, add services that perform various database operations, model the associations between the entities and create JPQL queries to fetch the necessary information.

After you have watched this series, you will not only know everything you need to know about JPA, you will also have used it to build your first persistence layer.

Cheat Sheet Package: Remember All the Important Details

Remembering all the mapping annotations, JPA's life cycle model and the EntityManager API can be tough.

That's why I created 7 cheat sheets highlighting all the important details that you need to build your own persistence layer. Put the files on your desktop or keep a printout beside your keyboard in order to have the most critical information at your fingertips whenever you need it.

About the Author

My name is Thorben Janssen, and I'm the author of the Amazon bestselling book Hibernate Tips - More than 70 solutions to common Hibernate problems.

For the last 15 years, I have been using Hibernate and JPA in all kinds of projects. From small ones with very aggressive timelines to huge projects that had to handle thousands of users.

The requirements of these applications were very different and I learned that Hibernate provides good solutions for all of them. You just have to understand the features along with their advantages and disadvantages.

I'm looking forward to showing you how to use Hibernate's advanced features so that you can implement complex persistence requirements with ease.

About the Author

My name is Thorben Janssen, and I'm the author of the Amazon bestselling book Hibernate Tips - More than 70 solutions to common Hibernate problems.

For the last 15 years, I have been using Hibernate and JPA in all kinds of projects. From small ones with very aggressive timelines to huge projects that had to handle thousands of users.

The requirements of these applications were very different and I learned that Hibernate provides good solutions for all of them. You just have to understand the features with their advantages and disadvantages.

​I'm looking forward to showing you how to use Hibernate's advanced features so that you implement complex persistence requirements with ease.

Videos, Example Projects, Exercises ...

Training Videos

Watch 17 video lectures and start using JPA in your projects.

Example Projects

Get all example projects that are used during the training.

Lifetime Access

Study at your own pace with lifetime access to all training material.

Exercises

Try what you have learned in practical exercises.

Handout

Get a comprehensive handout with commented slides.

View Offline

Download your video lectures to view them offline.

Start Today! Choose Your Training Package

Watch the videos only and study on your own 
or use your new knowledge in exercises and get a participation certificate.

Select the package that fits best to your personal style of learning.

Master Class

  • All Video Lectures
  • Example Projects for All Lectures
  • Slides for All Lectures
  • Bonus 1: "I don't have time" Schedule
  • Bonus 2: Your 1st Persistence Layer
  • Bonus 3: Cheat Sheet Package

Enroll Now

Certification Class

  • All Video Lectures
  • Example Projects for All Lectures
  • Practical Exercises & Solutions
  • Comprehensive Handout
  • Download Videos to View Offline
  • Participation Certificate
  • Bonus 1: "I don't have time" Schedule
  • Bonus 2: Your 1st Persistence Layer
  • Bonus 3: Cheat Sheet Package

Enroll Now

Team Licenses

Get your team certified with a discounted team licence for the
Certification Class of the JPA for Beginners Online Training course.

I'm also available for in-house training. Contact me for more information!

30 Days Money Back Guarantee

I strongly believe in the value of this course and that it will help you to improve your understanding and usage of JPA. Therefore, I confidently back this course with my 30 Days Money Back Guarantee!

If you are not satisfied with the course, contact me within 30 days of your registration and I will refund your money without any further questions.

FAQ

May I watch an example lecture?

Sure! Here is a lecture about basic entity mappings:


What version of JPA is this training based on?

The code examples are based on JPA 2.2 but you can use almost all of it with JPA 2.1 and 2.0.


Which JPA implementation do I need to use?

There are multiple JPA implementations available and you can use the code examples with all of them. That's one of the great benefits of the JPA specification. As long as you follow the standard, you can run the same code with all compliant implementations of the JPA specification.


How long do I have access to the course?

You get life-time access to all training materials. That includes the lectures, example projects, exercises and handouts.


Do I have to have any experience with JPA or one of its implementations?

No! You don't need to know anything about JPA. I will show you everything you need to know in this online training.
But you should be familiar with Java, SQL and relational table models.


What other technologies should I be familiar with?

You should be familiar with Java, of course ;-) and have at least some basic knowledge of Relational Database Management Systems (RDBMSs) and SQL.


What happens if I don't like the training material?

Don't worry. Just send an email to thorben@thoughts-on-java.org within the first 30 days after your registration and you'll get your money back.


Didn't find the answer you're looking for?

Let's talk about it. Please send me an email to thorben@thoughts-on-java.org.