Marco Codes Live: Gavin King and Hibernate 6.3 [Video]
In this video, explore the newly released Hibernate 6.3 and discover alternative approaches to frameworks like Spring Data.
Join the DZone community and get the full member experience.Join For Free
In the video below, we'll cover the newly released Hibernate 6.3.
With its annotation processing capabilities, it offers alternative approaches to frameworks like Spring Data JPA, and we'll explore those with a bit of live coding.
What’s in the Video?
We'll start off with a tiny story about how this webinar came about. I read the new "Introduction to Hibernate 6" written by Gavin King, which includes many opinions on how to do data persistence with Java in general. I thought it might make sense to not only have a theoretical discussion about this, but take an existing Spring Boot/Spring Data JPA project, and replace its bits and pieces one by one with the new approach offered by Hibernate 6.3.
Hence, we'll set the baseline for this video by quickly going over my Google Photos Clone project, which lets you create thumbnails for directories on your hard drive, for example, and display them on a (not yet nice-looking) HTML page.
There are just a couple of data queries the application currently executes, mainly to select all photos, check if they already exist in a database, and save them to a database. So we'll go about replacing those one by one.
Let's start with the
select query. We'll use the newly introduced
@HQL annotation to replace the Spring Data JPA
select query with it. Along the way, we'll learn that we don't need to encode the query into the method name itself and that we also have the flexibility to use helper objects like
Page to customize our queries.
Once we restarted our application to find out it is still working, let's take care of the
"exists" query. It needs a bit of custom-written HQL, but along the way, we'll learn about compile-time validation of our queries - the Hibernate annotation processor does that out of the box.
exists query is working, we'll take care of the
last query, saving new images to the database. That gives us room to discuss architectural questions, like "Do we need another abstraction on top of our annotated queries?" and "How do we manage and structure queries in bigger projects?"
In the last quarter of the live-stream we'll discuss other popular questions that arise with Hibernate on a day-to-day basis:
- Should you use sessions vs. stateless sessions?
- Should you use fetch profiles extensively?
- Is it ok to use plain SQL with Hibernate?
- Is it ok to use Hibernate-specific annotations as opposed to JPA ones?
- And many more
All in all, the livestream should be of huge value for anyone using Hibernate in their projects (which the majority of Java projects likely do). Enjoy!
Opinions expressed by DZone contributors are their own.