Video in progress

For a new high-load service, how do you choose between blocking JPA/Hibernate, Hibernate Reactive and R2DBC?

In most cases blocking Hibernate + virtual threads is enough and the simplest for the team. The reactive stack only pays off when the whole service is reactive (WebFlux, streaming, thousands of open connections); Hibernate Reactive keeps the ORM convenience, while R2DBC is much lower level.

📖 Answer

The main question is: which part of the service is waiting? If one request makes one or two SQL queries and returns, the database itself is the limit. A reactive driver does not make the database faster.

Blocking JPA. The biggest ecosystem: Spring Data, Envers, Flyway integration, debugging, readable stack traces. With Java 21 virtual threads, the main argument ("you need lots of threads") has nearly disappeared.

Hibernate Reactive. A Mutiny or CompletionStage API on top of the Vert.x SQL client. Entity mapping, lazy loading (through an explicit fetch()) and dirty checking are kept. But Session is not thread-safe and must be used in a single context inside the reactive chain; the integration with Spring is not as smooth as in Quarkus. The team has to know two mental models.

R2DBC (+ Spring Data R2DBC). No persistence context, no lazy loading, no associations: basically a reactive JdbcTemplate. Good for simple tables and high concurrency.

My selection logic:

  • a typical business service → blocking Hibernate, with virtual threads if needed;
  • streaming, SSE/WebSocket, an already fully reactive stack → R2DBC, or Hibernate Reactive (if the domain is rich);
  • mixed: reactive WebFlux + blocking JPA is the worst option; wrapping everything in boundedElastic combines the downsides of both worlds.

On top of that, observability tools (tracing, MDC) need extra setup on a reactive stack, so I include that in the evaluation too.