Interface Queryable<T>

    • 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 the getFirst() method.
      default java.util.concurrent.CompletableFuture<java.lang.Void> getFirstAsync​(java.util.function.Consumer<? super java.util.Optional<T>> callback)
      The asynchronous version of the getFirst() method.
      java.lang.String getQuery()
      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 the toArray() method.
      default java.util.concurrent.CompletableFuture<java.lang.Void> toArrayAsync​(java.util.function.Consumer<? super T[]> callback)
      The asynchronous version of the toArray() method.
      java.util.List<T> toList()
      Executes the query and returns the result as a List
      default java.util.concurrent.CompletableFuture<java.util.List<T>> toListAsync()
      The asynchronous version of the toList() method.
      default java.util.concurrent.CompletableFuture<java.lang.Void> toListAsync​(java.util.function.Consumer<? super java.util.List<T>> callback)
      The asynchronous version of the toList() method.
      java.util.stream.Stream<T> toStream()
      Executes the query and returns the result as a Stream
      default java.util.concurrent.CompletableFuture<java.util.stream.Stream<T>> toStreamAsync()
      The asynchronous version of the toStream() 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 the toStream() 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 Optional if there is at least one row. Otherwise Optional.empty() is returned. If the value from the database is null, an empty Optional is also returned.
      • toList

        java.util.List<T> toList()
        Executes the query and returns the result as a List
        Returns:
        A list of entities representing the result rows.
      • toStream

        java.util.stream.Stream<T> toStream()
        Executes the query and returns the result as a Stream
        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 the getFirst() method.
        Returns:
        The asynchronous operation which will retrieve the data from the database. Custom handling for the CompletableFuture can 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 the getFirst() 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 the toList() method.
        Returns:
        The asynchronous operation which will retrieve the data from the database. Custom handling for the CompletableFuture can 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 the toList() 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 the toStream() method.
        Returns:
        The asynchronous operation which will retrieve the data from the database. Custom handling for the CompletableFuture can 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 the toStream() 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 the toArray() method.
        Returns:
        The asynchronous operation which will retrieve the data from the database. Custom handling for the CompletableFuture can 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 the toArray() 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.