quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

quarkus-hibernate-reactive does not make StatelessSession available for injection

Open gavinking opened this issue 6 months ago • 25 comments

Description

The regular quarkus-hibernate-orm extension makes a Hibernate StatelessSession available for injection, which means that Jakarta Data repositories can be easily injected in user code.

But quarkus-hibernate-reactive does not do this for Mutiny.StatelessSession (nor even for Uni<Mutiny.StatelessSession>) and this means that injection of Jakarta Data repositories is an almost impossible task for an unsophisticated user.

Yes, it's possible to make this work by writing your own @Producer method on a @RequestScoped bean, and also adding a custom @Interceptor to make sure everything gets cleaned up properly, but this was a task that took me more than an hour, not counting the time I spent fixing tangential issues I ran into along the way.

Implementation ideas

@FroMage already has some discussion of this in the context of Panache here: https://github.com/quarkusio/quarkus/issues/46091, but this is actually more general and affects people who aren't using Panache.

gavinking avatar Apr 21 '25 20:04 gavinking