Class SessionOperations
- java.lang.Object
-
- io.quarkus.hibernate.reactive.panache.common.runtime.SessionOperations
-
public final class SessionOperations extends Object
Static util methods forMutiny.Session
.
-
-
Constructor Summary
Constructors Constructor Description SessionOperations()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static io.smallrye.mutiny.Uni<Void>
closeSession()
static org.hibernate.reactive.mutiny.Mutiny.Session
getCurrentSession()
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.(package private) static org.hibernate.reactive.mutiny.Mutiny.SessionFactory
getSessionFactory()
(package private) static org.hibernate.reactive.context.Context.Key<org.hibernate.reactive.mutiny.Mutiny.Session>
getSessionKey()
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.
-
-
-
Method Detail
-
withSessionOnDemand
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. 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:
getSession()
-
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
static io.smallrye.mutiny.Uni<Void> 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()
-
-