ADR-0095: Opt-in Hibernate Reactive stateless persistence provider for the persistence plugin ​
Context ​
TPF's foundational persistence plugin records domain step outputs across configured aspect boundaries (typically AFTER_STEP side effects) without changing pipeline business semantics. Its default reactive driver (ReactivePanachePersistenceProvider / PersistenceService in pipelineframework-runtime) relies on a managed Hibernate Reactive Mutiny.Session backed by Vert.x duplicated contexts and VertxContextSafetyToggle.
In high-throughput streaming pipelines (ONE_TO_MANY and MANY_TO_MANY), a managed persistence context adds overhead that the persistence aspect rarely needs:
- Every persisted step output is tracked in a first-level session cache for dirty-checking and lazy-loading proxies, even though TPF persistence side effects typically write self-contained snapshots.
- Keeping
ReactivePanachePersistenceProvideras the default preserves full backwards compatibility for existing applications whose entities rely on JPACascadeTypeor managed session behaviour, while applications persisting flat or self-contained snapshots benefit from an explicit stateless reactive provider. - On Quarkus 4,
quarkus-hibernate-reactiveships Hibernate Reactive 5 (5.1.0.CR3in Quarkus4.0.1) with nativeMutiny.SessionFactory.withStatelessTransactionandMutiny.StatelessSessionsupport directly on the reactive persistence stack, avoiding any need to pull blockingquarkus-hibernate-orm/quarkus-data-hibernateruntime dependencies intopersistence-plugin.
At the same time, ADR-0008 keeps aspect persistence distinct from durable control-plane stores (Command effects, Query capture, Await state, and execution state), and existing applications whose entities depend on JPA cascade graphs or dirty-checking continue to use the default managed-session path.
Decision ​
The Quarkus 4 foundational persistence plugin in pipelineframework-runtime provides an opt-in stateless reactive persistence provider (StatelessReactivePersistenceProvider) backed directly by Hibernate Reactive 5 Mutiny.SessionFactory.withStatelessTransaction / Mutiny.StatelessSession, while retaining ReactivePanachePersistenceProvider as the default when unconfigured.
1. Explicit stateless semantics without pulling blocking ORM dependencies ​
StatelessReactivePersistenceProviderresolvesMutiny.SessionFactorylazily from Quarkus ArC and executes writes insidesessionFactory.withStatelessTransaction(...)usingsession.insert(entity)forpersist(...)andsession.upsert(entity)forpersistOrUpdate(...)on a duplicated Vert.x context without first-level cache retention, dirty-checking, or implicit JPA relationship cascades.persistence-pluginstays strictly reactive and does not pull blockingquarkus-hibernate-orminto reactive-only service modules.- Failure rollback, duplicate/conflict surfacing, and transaction boundaries remain explicit and reactive without blocking Vert.x event-loop threads.
- This decision governs the foundational persistence plugin only. Durable control-plane stores (ADR-0018, ADR-0020, ADR-0044, ADR-0045, ADR-0046) and Hibernate
find.manyQuery providers (ADR-0022) retain their own separate contracts and authorities.
2. Dual-surface provider selection stays unchanged ​
- Applications select the active persistence provider through both aligned surfaces:
- runtime configuration:
persistence.provider.class=org.pipelineframework.plugin.persistence.provider.StatelessReactivePersistenceProvider - build-time compiler option:
-Apersistence.provider.class=org.pipelineframework.plugin.persistence.provider.StatelessReactivePersistenceProvider
- runtime configuration:
- Applications that do not set
persistence.provider.classcontinue to resolve the defaultReactivePanachePersistenceProviderwith full JPA cascade and managed-session semantics.
3. Upstream Hibernate Final tracking ​
- Because
quarkus-bom:4.0.1ships pre-Final Hibernate CR artefacts (hibernate-core:8.0.0.CR2andhibernate-reactive-core:5.1.0.CR3), TPF tracks upstream Hibernate ORM 8 / Hibernate Reactive 5.1 Final alignment in a subsequent Quarkus4.0.xpatch release.
Rationale ​
- Natural match for immutable pipeline persistence: Persisting step outputs in an
AFTER_STEPaspect is an append/upsert-style projection, not an ORM unit-of-work graph mutation. Removing first-level cache retention prevents unbounded session memory growth duringONE_TO_MANYstreams. - No blocking ORM creep: Using
Mutiny.SessionFactory.withStatelessTransactiondirectly keepspersistence-pluginfree of blockingquarkus-hibernate-ormtransitive dependencies. - Zero-surprise migration: Keeping
ReactivePanachePersistenceProvideras the default prevents silent breakage for existing JPA entity graphs that require cascades, while giving streaming applications an opt-in switch configured consistently viapersistence.provider.classand-Apersistence.provider.class.
Consequences ​
pipelineframework-runtime: ShipsStatelessReactivePersistenceProvideralongsideReactivePanachePersistenceProviderinpersistence-plugin, verified byStatelessReactivePersistenceProviderTestcovering entity validation, stateless transaction upsert, rollback/conflict propagation, and dual-surface provider selection.pipelineframework: Documents provider selection in Using plugins and records migration evidence in Quarkus 4.0 migration.- Applications & reference implementations: Applications persisting flat or self-contained records can opt in via
persistence.provider.class/-Apersistence.provider.class; existing applications relying on JPA cascades retain unchanged default behaviour.