Gavin King

Results 1136 comments of Gavin King

> there's a very very tiny bug in the code Fixed. There's also a problem if you want to start and commit a series of multiple transactions/sessions in the same...

@DavideD > I'm not against injecting the session per se. A lot of things have changed since then. But it's a bit unclear to me why we need it. I...

> I think that this would work, unless you use the injected `Mutiny.Session` lazily in the pipeline... because when someone subscribes to the returned Uni the injected proxy would not...

> I'm not sure if we should make `Mutiny.Session` available for injection. Perhaps `Uni` is enough? I like having both :)

~OK, scratch all of what I wrote above. I don't see a good way to:~ ~1. allow access to repositories from callbacks, *and* ~ ~2. also allow them to be...

> I don't see a good way to: > > - allow access to repositories from callbacks, and > - also allow them to be injected into "wider" scopes (e.g....

Wait wait wait. What if the code were this: ```java @AroundInvoke public Object withSession(InvocationContext invocationContext) throws Exception { if ( invocationContext.getMethod().getReturnType().equals(Uni.class) ) { return factory.withStatelessTransaction(session -> { requestScopedSession.setSession(session); try {...

I just tested it with this code: ```java @Inject Library library; @GET @Path("/books") public Uni allBooks() { return Uni.createFrom().voidItem() .chain(v-> Uni.createFrom().nullItem()) .chain(v -> library.byIsbn("xyz")) .onFailure().recoverWithNull() .chain(v -> library.allBooks()) .invoke(list ->...

So the best version I've come up with so far now looks like this: ```java import jakarta.enterprise.context.RequestScoped; import org.hibernate.reactive.mutiny.Mutiny; import org.hibernate.reactive.mutiny.delegation.MutinyStatelessSessionDelegator; @RequestScoped public class RequestScopedSession extends MutinyStatelessSessionDelegator { private Mutiny.StatelessSession...

And finally, after the addition of `getCurrentSession()` to `SessionFactory`, I can simplify the code to: ```java @WithSession @Interceptor public class WithSessionInterceptor { @Inject RequestScopedStatelessSession requestScopedStatelessSession; @Inject Mutiny.SessionFactory factory; @AroundInvoke public...