DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • When AI Crashes: Classifying Failure Modes in Safety-Critical Software
  • Unhandled Promise Rejections: The Tiny Mistake That Crashed Our Node.js App
  • Ranking Full-Text Search Results in PostgreSQL Using ts_rank and ts_rank_cd With Hibernate 6 and posjsonhelper
  • How Spring and Hibernate Simplify Web and Database Management

Trending

  • Spring AI Advisors: Chat Memory, Token Tracking, and Message Logging
  • LLM Integration in Enterprise Applications: A Practical Guide
  • Dear Micromanager: Your Distrust Has a Job; It’s Just Not the One You’re Doing
  • Throughput vs Goodput: The Performance Metric You Are Probably Ignoring in LLM Testing
  1. DZone
  2. Coding
  3. Java
  4. Hibernate and JPA Tutorial: Crash Course [Video]

Hibernate and JPA Tutorial: Crash Course [Video]

Ever looked for a comprehensive tutorial to Hibernate and JPA that is fun and entertaining at the same time? Look no further than this video tutorial.

By 
Marco Behler user avatar
Marco Behler
·
Aug. 26, 22 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
7.4K Views

Join the DZone community and get the full member experience.

Join For Free

Ever looked for a comprehensive tutorial to Hibernate and JPA that is fun and entertaining at the same time?  The video tutorial below is a crash course into the Hibernate and JPA universe. From mapping annotations and SessionFactory setup to HQL and criteria queries, we cover all the basics you’ll need to get started with Hibernate and JPA. 

What’s in the Video?

There are so many terms when it comes to Hibernate: Hibernate (i.e., JPA, HQL, JPQL, and SQL) that we first have to understand what Hibernate is and what problem it tries to solve. The core problem is mapping between Java classes and relational database tables.

Afterward, we'll jump right into the project. You can choose to clone the sample project to follow along with this video, and we'll dive deeper into what dependencies you need to get started with Hibernate. Hint: It's not that many. In fact, it's only one: even though modern stacks like Spring Boot might make you believe differently.

Once we have the dependencies sorted out, we'll have a look at Hibernate's mapping annotations. One of the core ways to let Hibernate know about your database tables is through annotations such as @Entity, @Table, @Column, and many more. We'll play with those. We'll also figure out that one of the most popular Hibernate books spends roughly 200 pages on mapping annotations. A lot of work you have to go through yourself, which cannot be condensed into just a video.

Having the dependencies and annotations set up correctly means we can now go about creating a SessionFactory. A SessionFactory essentially is Hibernate. It's the core class you want to use whenever you want to, for example, fire queries against a database, or simply just save one of your objects.

When the SessionFactory is up and running, we can start considering how to make basic CUD queries work. We can create, update, and delete, but not yet send queries. Hence, we'll use the SessionFactory to do just that, save and update a couple of users we had previously created.

Let's add an "R" to CUD and make it fully CRUD by executing HQL queries against the database. HQL queries are Hibernate's way of querying database tables, though you don't write your HQL against specific database tables; rather, against your mapped object hierarchy. At the end of the day, Hibernate will transform the HQL into SQL for you and you'll see it printed out in the console.

Up next, let's solve the big question of what JPA, the Java Persistence API actually is. By just swapping out a couple of classes, we can actually turn our application from a Hibernate application into a JPA application. We'll also talk about the real-life implications this actually has.

Every project, sooner or later, wants to create dynamic SQL queries. Hibernate/JPA's way of doing that is through its Criteria API. It's a bit cumbersome to use, but it does the job. Again, it's several dozen pages in the official documentation, but we'll try our best and cover the core concepts of the Criteria API.

Before we come to a close, we'll also spend some time figuring out where Hibernate/JPA fits into the Spring Boot universe and how it compares to other projects, such as Spring Data JPA.

By the end of this video, you should have a good grasp of basic Hibernate and we'll finish by giving you some tips on what to learn next to become a Hibernate expert.

Enjoy.


Crash (computing) Hibernate

Opinions expressed by DZone contributors are their own.

Related

  • When AI Crashes: Classifying Failure Modes in Safety-Critical Software
  • Unhandled Promise Rejections: The Tiny Mistake That Crashed Our Node.js App
  • Ranking Full-Text Search Results in PostgreSQL Using ts_rank and ts_rank_cd With Hibernate 6 and posjsonhelper
  • How Spring and Hibernate Simplify Web and Database Management

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook