Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quarkus Hibernate Reactive with Panache streamlines routine Java persistence by reducing entity and query boilerplate while exposing non-blocking database operations through Mutiny. This walkthrough follows Daniel Oh’s January 6, 2022 Red Hat Developer tutorial: a small CRUD API backed by PostgreSQL, with a Fruit entity and reactive endpoints. Its commands and extension names come from the Quarkus 2 era, so check the current Quarkus guide before applying them to a newer project.

What Hibernate Reactive and Panache simplify

Hibernate Reactive provides a reactive API for Hibernate ORM, using SmallRye Mutiny for non-blocking interactions with relational databases. Panache reduces routine persistence ceremony: its entity model can generate IDs, does not require conventional getters and setters for basic field access, and supplies common operations such as listAll, findById, and find. That can eliminate custom query code for straightforward CRUD tasks. It does not remove the need to design transactions, handle missing records, or choose suitable queries for more complex operations.

The tutorial’s stack combines Quarkus, Hibernate Reactive with Panache, the reactive PostgreSQL client, and RESTEasy Reactive. The key design point is to keep the request path reactive: endpoints return Mutiny Uni results rather than blocking for database work.

Choose a Panache style: active record or repository

Panache supports both styles; neither is a universal winner. Choose based on where your application’s persistence logic belongs and how the surrounding code is organized.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Consideration Active-record style Repository style
Where queries live On the entity, alongside its persistence operations. In a separate repository class.
Domain behavior Convenient when a small model’s persistence and behavior naturally belong together. Useful when you want entity data and persistence operations to remain separate.
Testing seam Static operations can be less convenient to replace or mock in tests. A repository object can provide an explicit dependency seam for tests.
Codebase consistency Fits a codebase already using Panache entities and methods on the model. Fits a codebase organized around injected repositories and separated data access.

The tutorial uses active record: Fruit extends PanacheEntity. For an existing project, consistency with its established pattern is usually a more useful deciding factor than treating either style as inherently superior.

Add the Quarkus extensions and start PostgreSQL

For the Quarkus 2-era project shown in the tutorial, add the reactive REST, JSON, Hibernate Reactive Panache, and PostgreSQL client extensions with Maven:

./mvnw quarkus:add-extension -Dextensions="resteasy-reactive,resteasy-reactive-jackson,hibernate-reactive-panache,reactive-pg-client"

The tutorial relies on Quarkus Dev Services to start a PostgreSQL container when a container engine is available. Start that engine, then launch development mode:

./mvnw quarkus:dev

Extension names and APIs may differ in newer Quarkus releases. Consult the current guide and use the extension names appropriate to your project rather than assuming this historical command remains current.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Java Persistence With Hibernate
  • Used Book in Good Condition

Define the entity and expose CRUD endpoints

The sample entity extends PanacheEntity, which provides an ID field and common active-record operations. The tutorial keeps the model deliberately small, with a public name field and constructors:

import io.quarkus.hibernate.reactive.panache.PanacheEntity;

public class Fruit extends PanacheEntity {
    public String name;

    public Fruit() {
    }

    public Fruit(String name) {
        this.name = name;
    }
}

Build the resource around reactive return values. The four routes in the example cover listing records, looking up a record by ID, creating a record, and deleting by ID:

  • GET /fruits returns all fruit records as a Uni.
  • GET /fruits/{id} finds a fruit by its ID and returns a Uni.
  • POST /fruits persists a new fruit and returns a Uni.
  • DELETE /fruits/{id} deletes by ID and returns a Uni.

Mark write operations with @ReactiveTransactional, as in the tutorial. A production API should also define its response behavior for invalid input, missing IDs, and delete requests for nonexistent rows; the tutorial’s basic CRUD outline does not establish a particular error-response policy.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Seed, exercise, and inspect the example

The tutorial seeds the database with Cherry, Apple, and Banana in import.sql. With the application running in development mode, use HTTPie or cURL to call the four routes and verify the returned data and write behavior. Quarkus Dev UI also provides a Hibernate ORM persistence-unit SQL inspection view, which can help show the SQL associated with persistence operations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Dev Services depends on a usable container engine; if PostgreSQL does not start automatically, check that the container runtime is running and available to the Quarkus process. The tutorial’s workflow assumes that development-time setup rather than a separately configured production database, so production connection and deployment settings must be supplied for the target environment.

What this tutorial does—and does not—establish

Daniel Oh’s Red Hat Developer tutorial was published January 6, 2022; its DZone mirror is dated January 14, 2022. It is a practical introduction to reducing persistence boilerplate and composing a reactive CRUD path, not a current-version compatibility guarantee or a performance study. The sources report no independent latency, throughput, or adoption measurements, so the example supports understanding the programming model, not claims that it will outperform a blocking design in a particular application.

For current terminology and supported patterns, consult the Quarkus Hibernate Reactive with Panache guide. The original walkthrough is available from Red Hat Developer.

Quick Recap

Bestseller No. 2
SaleBestseller No. 3
Java Persistence With Hibernate
Java Persistence With Hibernate
Used Book in Good Condition
$45.00
SaleBestseller No. 4

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.