public class ExecutorAsyncOperations extends java.lang.Object implements AsyncRepositoryOperations
AsyncRepositoryOperations
that delegates to a blocking operations and specified Executor
.
This can be used in absence of true asynchronous support at the driver level.
If a backing implementation provides a async API then the backing implementation should not use this class and instead directly implement the AsyncRepositoryOperations
interface.
Constructor and Description |
---|
ExecutorAsyncOperations(RepositoryOperations operations,
java.util.concurrent.Executor executor)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
<T> java.util.concurrent.CompletableFuture<java.lang.Long> |
count(PagedQuery<T> pagedQuery)
Counts all results for the given query.
|
<T> java.util.concurrent.CompletableFuture<java.lang.Number> |
deleteAll(BatchOperation<T> operation)
Deletes all the entities of the given type.
|
java.util.concurrent.CompletableFuture<java.lang.Number> |
executeUpdate(PreparedQuery<?,java.lang.Number> preparedQuery)
Executes an update for the given query and parameter values.
|
<T> java.util.concurrent.CompletableFuture<java.lang.Boolean> |
exists(PreparedQuery<T,java.lang.Boolean> preparedQuery)
Check with an record exists for the given query.
|
<T> java.util.concurrent.CompletableFuture<java.lang.Iterable<T>> |
findAll(PagedQuery<T> pagedQuery)
Finds all results for the given query.
|
<T,R> java.util.concurrent.CompletableFuture<java.lang.Iterable<R>> |
findAll(PreparedQuery<T,R> preparedQuery)
Finds all results for the given query.
|
<T> java.util.concurrent.CompletableFuture<T> |
findOne(java.lang.Class<T> type,
java.io.Serializable id)
Find one by ID.
|
<T,R> java.util.concurrent.CompletableFuture<R> |
findOne(PreparedQuery<T,R> preparedQuery)
Find one by Query.
|
<T> java.util.concurrent.CompletableFuture<T> |
findOptional(java.lang.Class<T> type,
java.io.Serializable id)
Find one by ID.
|
<T,R> java.util.concurrent.CompletableFuture<R> |
findOptional(PreparedQuery<T,R> preparedQuery)
Find one by Query.
|
<R> java.util.concurrent.CompletableFuture<Page<R>> |
findPage(PagedQuery<R> pagedQuery)
Find a page for the given entity and pageable.
|
java.util.concurrent.Executor |
getExecutor() |
<T> java.util.concurrent.CompletableFuture<T> |
persist(InsertOperation<T> entity)
Persist the entity returning a possibly new entity.
|
<T> java.util.concurrent.CompletableFuture<java.lang.Iterable<T>> |
persistAll(BatchOperation<T> operation)
Persist all the given entities.
|
<T> java.util.concurrent.CompletableFuture<T> |
update(UpdateOperation<T> operation)
Updates the entity returning a possibly new entity.
|
public ExecutorAsyncOperations(@NonNull RepositoryOperations operations, @NonNull java.util.concurrent.Executor executor)
operations
- The target operationsexecutor
- The executor to use.public java.util.concurrent.Executor getExecutor()
getExecutor
in interface AsyncRepositoryOperations
@NonNull public <T> java.util.concurrent.CompletableFuture<T> findOne(@NonNull java.lang.Class<T> type, @NonNull java.io.Serializable id)
AsyncRepositoryOperations
findOne
in interface AsyncRepositoryOperations
T
- The generic typetype
- The typeid
- The idpublic <T> java.util.concurrent.CompletableFuture<java.lang.Boolean> exists(@NonNull PreparedQuery<T,java.lang.Boolean> preparedQuery)
AsyncRepositoryOperations
exists
in interface AsyncRepositoryOperations
T
- The declaring typepreparedQuery
- The query@NonNull public <T,R> java.util.concurrent.CompletableFuture<R> findOne(@NonNull PreparedQuery<T,R> preparedQuery)
AsyncRepositoryOperations
findOne
in interface AsyncRepositoryOperations
T
- The generic resultTypeR
- The result typepreparedQuery
- The prepared query@NonNull public <T> java.util.concurrent.CompletableFuture<T> findOptional(@NonNull java.lang.Class<T> type, @NonNull java.io.Serializable id)
AsyncRepositoryOperations
findOptional
in interface AsyncRepositoryOperations
T
- The generic typetype
- The typeid
- The id@NonNull public <T,R> java.util.concurrent.CompletableFuture<R> findOptional(@NonNull PreparedQuery<T,R> preparedQuery)
AsyncRepositoryOperations
findOptional
in interface AsyncRepositoryOperations
T
- The generic resultTypeR
- The result typepreparedQuery
- The prepared query@NonNull public <T> java.util.concurrent.CompletableFuture<java.lang.Iterable<T>> findAll(@NonNull PagedQuery<T> pagedQuery)
AsyncRepositoryOperations
findAll
in interface AsyncRepositoryOperations
T
- The generic typepagedQuery
- The paged querypublic <T> java.util.concurrent.CompletableFuture<java.lang.Long> count(@NonNull PagedQuery<T> pagedQuery)
AsyncRepositoryOperations
count
in interface AsyncRepositoryOperations
T
- The generic typepagedQuery
- The paged query@NonNull public <T,R> java.util.concurrent.CompletableFuture<java.lang.Iterable<R>> findAll(@NonNull PreparedQuery<T,R> preparedQuery)
AsyncRepositoryOperations
findAll
in interface AsyncRepositoryOperations
T
- The entity typeR
- The result typepreparedQuery
- The prepared query@NonNull public <T> java.util.concurrent.CompletableFuture<T> persist(@NonNull InsertOperation<T> entity)
AsyncRepositoryOperations
persist
in interface AsyncRepositoryOperations
T
- The generic typeentity
- The entity operation@NonNull public <T> java.util.concurrent.CompletableFuture<T> update(@NonNull UpdateOperation<T> operation)
AsyncRepositoryOperations
update
in interface AsyncRepositoryOperations
T
- The generic typeoperation
- The entity operation@NonNull public <T> java.util.concurrent.CompletableFuture<java.lang.Iterable<T>> persistAll(@NonNull BatchOperation<T> operation)
AsyncRepositoryOperations
persistAll
in interface AsyncRepositoryOperations
T
- The generic typeoperation
- The batch operation@NonNull public java.util.concurrent.CompletableFuture<java.lang.Number> executeUpdate(@NonNull PreparedQuery<?,java.lang.Number> preparedQuery)
AsyncRepositoryOperations
executeUpdate
in interface AsyncRepositoryOperations
preparedQuery
- The prepared query@NonNull public <T> java.util.concurrent.CompletableFuture<java.lang.Number> deleteAll(@NonNull BatchOperation<T> operation)
AsyncRepositoryOperations
deleteAll
in interface AsyncRepositoryOperations
T
- The generic typeoperation
- The batch operationpublic <R> java.util.concurrent.CompletableFuture<Page<R>> findPage(@NonNull PagedQuery<R> pagedQuery)
AsyncRepositoryOperations
findPage
in interface AsyncRepositoryOperations
R
- The entity generic typepagedQuery
- The paged query