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 voidclear()(package private) static io.smallrye.mutiny.Uni<Void> closeSession(String persistenceUnitName) Close any session open for that persistence unit (stateless or managed, there can be only one opened at a time)static org.hibernate.reactive.mutiny.Mutiny.SessiongetCurrentSession(String persistenceUnitName) static org.hibernate.reactive.mutiny.Mutiny.StatelessSessiongetCurrentStatelessSession(String persistenceUnitName) 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.static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Session> getSession(String persistenceUnitName) static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.StatelessSession> If there is a reactive stateless session stored in the current Vert.x duplicated context then this stateless session is reused.static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.StatelessSession> getStatelessSession(String persistenceUnitName) static <T> io.smallrye.mutiny.Uni<T> withSession(String persistenceUnitName, Function<org.hibernate.reactive.mutiny.Mutiny.Session, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a named reactive 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 the default 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> withStatelessSession(String persistenceUnitName, Function<org.hibernate.reactive.mutiny.Mutiny.StatelessSession, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a named reactive stateless session.static <T> io.smallrye.mutiny.Uni<T> withStatelessSession(Function<org.hibernate.reactive.mutiny.Mutiny.StatelessSession, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of the default reactive stateless session.static <T> io.smallrye.mutiny.Uni<T> withStatelessTransaction(String persistenceUnitName, Supplier<io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive transaction.static <T> io.smallrye.mutiny.Uni<T> withStatelessTransaction(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> withStatelessTransaction(Supplier<io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive transaction.static <T> io.smallrye.mutiny.Uni<T> withTransaction(String persistenceUnitName, Supplier<io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive transaction.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 providedUnicompletes.- 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 managed session is reused if possible.- Type Parameters:
T-- Parameters:
work-- Returns:
- a new
Uni
-
withTransaction
public static <T> io.smallrye.mutiny.Uni<T> withTransaction(String persistenceUnitName, 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
-
withStatelessTransaction
public static <T> io.smallrye.mutiny.Uni<T> withStatelessTransaction(Supplier<io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive transaction. An existing stateless session is reused if possible.- Type Parameters:
T-- Parameters:
work-- Returns:
- a new
Uni
-
withStatelessTransaction
public static <T> io.smallrye.mutiny.Uni<T> withStatelessTransaction(String persistenceUnitName, Supplier<io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a reactive transaction. An existing stateless session is reused if possible.- Type Parameters:
T-- Parameters:
work-- Returns:
- a new
Uni
-
withStatelessTransaction
public static <T> io.smallrye.mutiny.Uni<T> withStatelessTransaction(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 stateless session is reused if possible.- Type Parameters:
T-- Parameters:
work-- Returns:
- a new
Uni
-
withSession
public static <T> io.smallrye.mutiny.Uni<T> withSession(String persistenceUnitName, Function<org.hibernate.reactive.mutiny.Mutiny.Session, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a named reactive session. An existing session is reused if possible.- Type Parameters:
T-- Parameters:
persistenceUnitName-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 the default reactive session. An existing session is reused if possible.- Type Parameters:
T-- Parameters:
work-- Returns:
- a new
Uni
-
withStatelessSession
public static <T> io.smallrye.mutiny.Uni<T> withStatelessSession(String persistenceUnitName, Function<org.hibernate.reactive.mutiny.Mutiny.StatelessSession, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of a named reactive stateless session. An existing stateless session is reused if possible.- Type Parameters:
T-- Parameters:
persistenceUnitName-work-- Returns:
- a new
Uni
-
withStatelessSession
public static <T> io.smallrye.mutiny.Uni<T> withStatelessSession(Function<org.hibernate.reactive.mutiny.Mutiny.StatelessSession, io.smallrye.mutiny.Uni<T>> work) Performs the work in the scope of the default reactive stateless 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
-
getSession
public static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Session> getSession(String persistenceUnitName) -
getStatelessSession
public static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.StatelessSession> getStatelessSession()If there is a reactive stateless session stored in the current Vert.x duplicated context then this stateless session is reused.However, if there is no reactive stateless session found then:
- if the current vertx duplicated context is marked as "lazy" then a new stateless session is opened and stored it in the context
- otherwise an exception thrown
- Returns:
- the
Mutiny.Session - Throws:
IllegalStateException- If no reactive stateless session was found in the context and the context was not marked to open a new session lazily
-
getStatelessSession
public static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.StatelessSession> getStatelessSession(String persistenceUnitName) -
getCurrentSession
public static org.hibernate.reactive.mutiny.Mutiny.Session getCurrentSession(String persistenceUnitName) - Returns:
- the current reactive session stored in the context, or
nullif no session exists
-
getCurrentStatelessSession
public static org.hibernate.reactive.mutiny.Mutiny.StatelessSession getCurrentStatelessSession(String persistenceUnitName) - Returns:
- the current reactive stateless session stored in the context, or
nullif no stateless session exists
-
closeSession
Close any session open for that persistence unit (stateless or managed, there can be only one opened at a time) -
clear
static void clear()
-