Class SessionOperations
java.lang.Object
io.quarkus.hibernate.reactive.panache.common.runtime.SessionOperations
Static util methods for
Mutiny.Session
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static void
clear()
(package private) static io.smallrye.mutiny.Uni<Void>
static org.hibernate.reactive.mutiny.Mutiny.Session
static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Session>
If there is a reactive session stored in the current Vert.x duplicated context then this session is reused.(package private) static org.hibernate.reactive.mutiny.Mutiny.SessionFactory
(package private) static org.hibernate.reactive.context.Context.Key<org.hibernate.reactive.mutiny.Mutiny.Session>
static <T> io.smallrye.mutiny.Uni<T>
withSession
(Function<org.hibernate.reactive.mutiny.Mutiny.Session, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive session.(package private) static <T> io.smallrye.mutiny.Uni<T>
withSessionOnDemand
(Supplier<io.smallrye.mutiny.Uni<T>> work) Marks the current vertx duplicated context as "lazy" which indicates that a reactive session should be opened lazily if needed.static <T> io.smallrye.mutiny.Uni<T>
withTransaction
(Function<org.hibernate.reactive.mutiny.Mutiny.Transaction, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive transaction.static <T> io.smallrye.mutiny.Uni<T>
withTransaction
(Supplier<io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive transaction.
-
Constructor Details
-
SessionOperations
public SessionOperations()
-
-
Method Details
-
withSessionOnDemand
Marks the current vertx duplicated context as "lazy" which indicates that a reactive session should be opened lazily if needed. The opened session is eventually closed and the marking key is removed when the providedUni
completes.- Type Parameters:
T
-- Parameters:
work
-- Returns:
- a new
Uni
- See Also:
-
withTransaction
public static <T> io.smallrye.mutiny.Uni<T> withTransaction(Supplier<io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive transaction. An existing session is reused if possible.- Type Parameters:
T
-- Parameters:
work
-- Returns:
- a new
Uni
-
withTransaction
public static <T> io.smallrye.mutiny.Uni<T> withTransaction(Function<org.hibernate.reactive.mutiny.Mutiny.Transaction, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive transaction. An existing session is reused if possible.- Type Parameters:
T
-- Parameters:
work
-- Returns:
- a new
Uni
-
withSession
public static <T> io.smallrye.mutiny.Uni<T> withSession(Function<org.hibernate.reactive.mutiny.Mutiny.Session, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive session. An existing session is reused if possible.- Type Parameters:
T
-- Parameters:
work
-- Returns:
- a new
Uni
-
getSession
public static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Session> getSession()If there is a reactive session stored in the current Vert.x duplicated context then this session is reused.However, if there is no reactive session found then:
- if the current vertx duplicated context is marked as "lazy" then a new session is opened and stored it in the context
- otherwise an exception thrown
- Returns:
- the
Mutiny.Session
- Throws:
IllegalStateException
- If no reactive session was found in the context and the context was not marked to open a new session lazily
-
getCurrentSession
public static org.hibernate.reactive.mutiny.Mutiny.Session getCurrentSession()- Returns:
- the current reactive session stored in the context, or
null
if no session exists
-
closeSession
-
getSessionKey
static org.hibernate.reactive.context.Context.Key<org.hibernate.reactive.mutiny.Mutiny.Session> getSessionKey() -
getSessionFactory
static org.hibernate.reactive.mutiny.Mutiny.SessionFactory getSessionFactory() -
clear
static void clear()
-