Class Panache


  • public class Panache
    extends Object
    Utility class for Panache.
    Author:
    Stéphane Épardaud
    • Constructor Summary

      Constructors 
      Constructor Description
      Panache()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Transaction> currentTransaction()
      Returns the current transaction, if any, or null.
      static io.smallrye.mutiny.Uni<Integer> executeUpdate​(String query, io.quarkus.panache.common.Parameters params)
      Executes a database update operation and return the number of rows operated on.
      static io.smallrye.mutiny.Uni<Integer> executeUpdate​(String query, Object... params)
      Executes a database update operation and return the number of rows operated on.
      static io.smallrye.mutiny.Uni<Integer> executeUpdate​(String query, Map<String,​Object> params)
      Executes a database update operation and return the number of rows operated on.
      static io.smallrye.mutiny.Uni<Void> flush()
      Flush all pending changes to the database.
      static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Session> getSession()
      Returns the current Mutiny.Session
      static <T> io.smallrye.mutiny.Uni<T> withTransaction​(Supplier<io.smallrye.mutiny.Uni<T>> work)
      Performs the given work within the scope of a database transaction, automatically flushing the session.
    • Constructor Detail

      • Panache

        public Panache()
    • Method Detail

      • getSession

        public static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Session> getSession()
        Returns the current Mutiny.Session
        Returns:
        the current Mutiny.Session
      • withTransaction

        public static <T> io.smallrye.mutiny.Uni<T> withTransaction​(Supplier<io.smallrye.mutiny.Uni<T>> work)
        Performs the given work within the scope of a database transaction, automatically flushing the session. The transaction will be rolled back if the work completes with an uncaught exception, or if Mutiny.Transaction.markForRollback() is called.
        Type Parameters:
        T - The function's return type
        Parameters:
        work - The function to execute in the new transaction
        Returns:
        the result of executing the function
        See Also:
        currentTransaction()
      • executeUpdate

        public static io.smallrye.mutiny.Uni<Integer> executeUpdate​(String query,
                                                                    Object... params)
        Executes a database update operation and return the number of rows operated on.
        Parameters:
        query - a normal HQL query
        params - optional list of indexed parameters
        Returns:
        the number of rows operated on.
      • executeUpdate

        public static io.smallrye.mutiny.Uni<Integer> executeUpdate​(String query,
                                                                    Map<String,​Object> params)
        Executes a database update operation and return the number of rows operated on.
        Parameters:
        query - a normal HQL query
        params - Map of named parameters
        Returns:
        the number of rows operated on.
      • executeUpdate

        public static io.smallrye.mutiny.Uni<Integer> executeUpdate​(String query,
                                                                    io.quarkus.panache.common.Parameters params)
        Executes a database update operation and return the number of rows operated on.
        Parameters:
        query - a normal HQL query
        params - Parameters of named parameters
        Returns:
        the number of rows operated on.
      • flush

        public static io.smallrye.mutiny.Uni<Void> flush()
        Flush all pending changes to the database.
        Returns:
        void
      • currentTransaction

        public static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Transaction> currentTransaction()
        Returns the current transaction, if any, or null.
        Returns:
        the current transaction, if any, or null.
        See Also:
        withTransaction(Supplier)