Class Panache
java.lang.Object
io.quarkiverse.groovy.hibernate.reactive.panache.Panache
Utility class for Panache.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Transaction>Returns the current transaction, if any, ornull.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>Returns the currentMutiny.Sessionstatic <T> io.smallrye.mutiny.Uni<T>withSession(Supplier<io.smallrye.mutiny.Uni<T>> uniSupplier) Obtains aUniwithin the scope of a reactive 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 Details
-
Panache
public Panache()
-
-
Method Details
-
withSession
public static <T> io.smallrye.mutiny.Uni<T> withSession(Supplier<io.smallrye.mutiny.Uni<T>> uniSupplier) Obtains aUniwithin the scope of a reactive session. If a reactive session exists then it is reused. If it does not exist then open a new session that is automatically closed when the providedUnicompletes.- Returns:
- a new
Uni
-
getSession
public static io.smallrye.mutiny.Uni<org.hibernate.reactive.mutiny.Mutiny.Session> getSession()Returns the currentMutiny.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 ifMutiny.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:
-
executeUpdate
Executes a database update operation and return the number of rows operated on.- Parameters:
query- a normal HQL queryparams- 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 queryparams-Mapof 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 queryparams-Parametersof named parameters- Returns:
- the number of rows operated on.
-
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, ornull.- Returns:
- the current transaction, if any, or
null. - See Also:
-