Interface Queryable<T>
-
- All Known Implementing Classes:
EntityProjectionQuery,EntityQuery
public interface Queryable<T>- Author:
- Collin Alpert
-
-
Method Summary
Modifier and Type Method Description java.util.Optional<T>getFirst()Gets the first value from the database result.default java.util.concurrent.CompletableFuture<java.util.Optional<T>>getFirstAsync()The asynchronous version of thegetFirst()method.default java.util.concurrent.CompletableFuture<java.lang.Void>getFirstAsync(java.util.function.Consumer<? super java.util.Optional<T>> callback)The asynchronous version of thegetFirst()method.java.lang.StringgetQuery()Responsible for building and returning the individual DQL statement.T[]toArray()Executes a new query and returns the result as an array.default java.util.concurrent.CompletableFuture<T[]>toArrayAsync()The asynchronous version of thetoArray()method.default java.util.concurrent.CompletableFuture<java.lang.Void>toArrayAsync(java.util.function.Consumer<? super T[]> callback)The asynchronous version of thetoArray()method.java.util.List<T>toList()Executes the query and returns the result as aListdefault java.util.concurrent.CompletableFuture<java.util.List<T>>toListAsync()The asynchronous version of thetoList()method.default java.util.concurrent.CompletableFuture<java.lang.Void>toListAsync(java.util.function.Consumer<? super java.util.List<T>> callback)The asynchronous version of thetoList()method.java.util.stream.Stream<T>toStream()Executes the query and returns the result as aStreamdefault java.util.concurrent.CompletableFuture<java.util.stream.Stream<T>>toStreamAsync()The asynchronous version of thetoStream()method.default java.util.concurrent.CompletableFuture<java.lang.Void>toStreamAsync(java.util.function.Consumer<? super java.util.stream.Stream<T>> callback)The asynchronous version of thetoStream()method.
-
-
-
Method Detail
-
getFirst
java.util.Optional<T> getFirst()
Gets the first value from the database result. This method should be used when only one result is expected.- Returns:
- The first row as an entity wrapped in an
Optionalif there is at least one row. OtherwiseOptional.empty()is returned. If the value from the database isnull, an emptyOptionalis also returned.
-
toList
java.util.List<T> toList()
Executes the query and returns the result as aList- Returns:
- A list of entities representing the result rows.
-
toStream
java.util.stream.Stream<T> toStream()
Executes the query and returns the result as aStream- Returns:
- A list of entities representing the result rows.
-
toArray
T[] toArray()
Executes a new query and returns the result as an array.- Returns:
- An array of entities representing the result rows.
-
getFirstAsync
default java.util.concurrent.CompletableFuture<java.util.Optional<T>> getFirstAsync()
The asynchronous version of thegetFirst()method.- Returns:
- The asynchronous operation which will retrieve the data from the database.
Custom handling for the
CompletableFuturecan be done here. - See Also:
getFirst()
-
getFirstAsync
default java.util.concurrent.CompletableFuture<java.lang.Void> getFirstAsync(java.util.function.Consumer<? super java.util.Optional<T>> callback)
The asynchronous version of thegetFirst()method.- Parameters:
callback- The action to be applied to the result once it is fetched from the database.- Returns:
- The asynchronous operation which will retrieve the data from the database and apply the given action to the result.
- See Also:
getFirst()
-
toListAsync
default java.util.concurrent.CompletableFuture<java.util.List<T>> toListAsync()
The asynchronous version of thetoList()method.- Returns:
- The asynchronous operation which will retrieve the data from the database.
Custom handling for the
CompletableFuturecan be done here. - See Also:
toList()
-
toListAsync
default java.util.concurrent.CompletableFuture<java.lang.Void> toListAsync(java.util.function.Consumer<? super java.util.List<T>> callback)
The asynchronous version of thetoList()method.- Parameters:
callback- The action to be applied to the result once it is fetched from the database.- Returns:
- The asynchronous operation which will retrieve the data from the database and apply the given action to the result.
- See Also:
toList()
-
toStreamAsync
default java.util.concurrent.CompletableFuture<java.util.stream.Stream<T>> toStreamAsync()
The asynchronous version of thetoStream()method.- Returns:
- The asynchronous operation which will retrieve the data from the database.
Custom handling for the
CompletableFuturecan be done here. - See Also:
toStream()
-
toStreamAsync
default java.util.concurrent.CompletableFuture<java.lang.Void> toStreamAsync(java.util.function.Consumer<? super java.util.stream.Stream<T>> callback)
The asynchronous version of thetoStream()method.- Parameters:
callback- The action to be applied to the result once it is fetched from the database.- Returns:
- The asynchronous operation which will retrieve the data from the database and apply the given action to the result.
- See Also:
toStream()
-
toArrayAsync
default java.util.concurrent.CompletableFuture<T[]> toArrayAsync()
The asynchronous version of thetoArray()method.- Returns:
- The asynchronous operation which will retrieve the data from the database.
Custom handling for the
CompletableFuturecan be done here. - See Also:
toArray()
-
toArrayAsync
default java.util.concurrent.CompletableFuture<java.lang.Void> toArrayAsync(java.util.function.Consumer<? super T[]> callback)
The asynchronous version of thetoArray()method.- Parameters:
callback- The action to be applied to the result once it is fetched from the database.- Returns:
- The asynchronous operation which will retrieve the data from the database and apply the given action to the result.
- See Also:
toArray()
-
getQuery
java.lang.String getQuery()
Responsible for building and returning the individual DQL statement.- Returns:
- The DQL statement which fetches data from the database.
-
-