Package csw.database.javadsl
Class JooqHelper
java.lang.Object
csw.database.javadsl.JooqHelper
A java helper wrapping few of the Jooq operations.
JOOQ
is a library that provides the mechanism to communicate with
Database server. To know in detail about Jooq please refer {@link https://www.jooq.org/learn/}.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableFuture<int[]>
executeBatch
(org.jooq.Queries queries) Executes the batch of queries asynchronously.static <R> CompletableFuture<List<R>>
fetchAsync
(org.jooq.ResultQuery<org.jooq.Record> query, Class<R> klass) Fetches the result in a CompletableFuture.
-
Constructor Details
-
JooqHelper
public JooqHelper()
-
-
Method Details
-
executeBatch
Executes the batch of queries asynchronously. It wraps the Jooq's DSLContext#executeBatch() in a CompletableFuture and sends the entire batch of queries to database server for execution.- Parameters:
queries
- A Jooq type that represents a set of queries to execute in batch- Returns:
- A completable future that completes with an array of integers. The integer, if it is greater than or equal to zero, indicates that the command was processed successfully and is an update count giving the number of rows in the database that were affected by the command's execution.
-
fetchAsync
public static <R> CompletableFuture<List<R>> fetchAsync(org.jooq.ResultQuery<org.jooq.Record> query, Class<R> klass) Fetches the result in a CompletableFuture. It is a wrapper on Jooq's ResultQuery#fetchAsync().- Parameters:
query
- the select query to fetch the data from databaseklass
- the class of type'R'
used to cast the result data- Returns:
- a CompletableFuture that completes with a list of data
'R'
-