Skip to content

Fix Quarkus Hibernate ORM Not Persisting

DodaTech Updated 2026-06-24 1 min read

In this tutorial, you'll learn about Fix Quarkus Hibernate ORM Not Persisting. We cover key concepts, practical examples, and best practices.

The Problem

Entities are not persisted to the database in Quarkus. Queries return empty results.

Quick Fix

Configure datasource

Wrong:

# No datasource
quarkus.hibernate-orm.database.generation=update

Output:

No connection

Right:

quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=user
quarkus.datasource.password=pass
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/db

Output:

Datasource configured

Enable Hibernate ORM

Wrong:

# No hibernate config
quarkus.hibernate-orm.database.generation=update

Output:

Schema not created

Right:

quarkus.hibernate-orm.database.generation=update
quarkus.hibernate-orm.log.sql=true

Output:

Hibernate ORM enabled

Use @Transactional

Wrong:

public void saveProduct(Product p) {
    productDao.persist(p);
} // No transaction

Output:

Not persisted

Right:

@Transactional
public void saveProduct(Product p) {
    productDao.persist(p);
}

Output:

Transaction commits

Prevention

  • Configure datasource properties
  • Enable Hibernate ORM with database.generation
  • Wrap persistence operations in @Transactional

Common Mistakes with hibernate

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors

These mistakes appear frequently in real-world QUARKUS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does persist() not save to the database?

Quarkus requires @Transactional for write operations to flush to the database.

This quick fix is part of the DodaTech Spring & JVM ecosystem series. Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro