Class SessionOperations

java.lang.Object
io.quarkus.hibernate.reactive.panache.common.runtime.SessionOperations

public final class SessionOperations extends Object
Static util methods for Mutiny.Session.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static void
     
    (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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SessionOperations

      public SessionOperations()
  • Method Details

    • 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 provided Uni 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:

      1. if the current vertx duplicated context is marked as "lazy" then a new session is opened and stored it in the context
      2. 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()
    • clear

      static void clear()