I am using Quarkus version 2.11.1.Final
. With the following `io.quarkus dependencies:
- smallrye-mutiny-vertx-web-client
- quarkus-resteasy-reactive
- quarkus-hibernate-reactive
In a long rest process, I am trying to persist several entities but I get the following error while doing one of the validations.
The current operation requires a safe (isolated) Vert.x sub-context, but the current context hasn't been flagged as such.
You can still use Hibernate Reactive, you just need to avoid using the methods which implicitly require accessing the stateful context, such as MutinySessionFactory#withTransaction and #withSession.
In order to persist a Collection of entities I am using:
@Inject
Mutiny.SessionFactory sf;
public Uni<List<T>> createAll(List<T> t) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("#createAll(T)... {}", t);
}
return sf.withTransaction(
(s, t) -> s.persistAll((Object[]) t.toArray(new T[0]))
.replaceWith(t));
}
I have already try to change the previous return to:
return sf.withStatelessTransaction((s, t) ->s.insertAll((Object[]) t.toArray(new T[0]))
.replaceWith(t));
But I still getting the same error. Anyone knows how can I handle the vertx context inside Quarkus or anyway of persisting the entities without getting this error?
> createAll(List t) {` called? You need to be on a Vert.x context.
– Clement Aug 24 '22 at 12:32