Search⌘ K
AI Features

Hibernate Reactive

Explore how to implement Hibernate Reactive in Quarkus to enable non-blocking database operations. Learn to add necessary dependencies, use the reactive API with PostgreSQL, and simplify development with Panache using active record and repository patterns. Gain practical skills to build responsive reactive applications.

Hibernate Reactive is the reactive API for the Hibernate ORM. It adds support for non-blocking database drivers to enable a reactive style of interaction with the database.

Adding the extensions

To use the Hibernate Reactive extension, we need to add a couple of dependencies, the first being the extension itself, called quarkus-hibernate-reactive. The second dependency is the reactive JDBC driver for the chosen database. Quarkus offers a list of extensions to handle different types of databases, which include:

  • quarkus-reactive-mysql-client used for MySQL.
  • quarkus-reactive-oracle-client used for Oracle Database.
  • quarkus-reactive-pg-client used for PostgreSQL.

Note: In the rest of the course, we’ll use PostgreSQL as the reactive SQL database.

After adding the dependencies, we should have the below new lines in our pom.xml (or build.gradle) file.

XML
// Hibernate Reactive dependency
implementation("io.quarkus:quarkus-hibernate-reactive")
Reactive SQL client for PostgreSQL
implementation("io.quarkus:quarkus-reactive-pg-client")

Using Hibernate Reactive

Using the Reactive Hibernate API is ...