Interface QueryByExampleExecutor<T>

Type Parameters:
T -
All Known Subinterfaces:
ListQueryByExampleExecutor<T>

public interface QueryByExampleExecutor<T>
Interface to allow execution of Query by Example Example instances.
Since:
1.12
Author:
Mark Paluch, Christoph Strobl, Diego Krupitza
See Also:
  • Method Details

    • findOne

      <S extends T> Optional<S> findOne(Example<S> example)
      Returns a single entity matching the given Example or Optional.empty() if none was found.
      Parameters:
      example - must not be null.
      Returns:
      a single entity matching the given Example or Optional.empty() if none was found.
      Throws:
      IncorrectResultSizeDataAccessException - if the Example yields more than one result.
    • findAll

      <S extends T> Iterable<S> findAll(Example<S> example)
      Returns all entities matching the given Example. In case no match could be found an empty Iterable is returned.
      Parameters:
      example - must not be null.
      Returns:
      all entities matching the given Example.
    • findAll

      <S extends T> Iterable<S> findAll(Example<S> example, Sort sort)
      Returns all entities matching the given Example applying the given Sort. In case no match could be found an empty Iterable is returned.
      Parameters:
      example - must not be null.
      sort - the Sort specification to sort the results by, may be Sort.unsorted(), must not be null.
      Returns:
      all entities matching the given Example.
      Since:
      1.10
    • findAll

      <S extends T> Page<S> findAll(Example<S> example, Pageable pageable)
      Returns a Page of entities matching the given Example. In case no match could be found, an empty Page is returned.
      Parameters:
      example - must not be null.
      pageable - the pageable to request a paged result, can be Pageable.unpaged(), must not be null.
      Returns:
      a Page of entities matching the given Example.
    • count

      <S extends T> long count(Example<S> example)
      Returns the number of instances matching the given Example.
      Parameters:
      example - the Example to count instances for. Must not be null.
      Returns:
      the number of instances matching the Example.
    • exists

      <S extends T> boolean exists(Example<S> example)
      Checks whether the data store contains elements that match the given Example.
      Parameters:
      example - the Example to use for the existence check. Must not be null.
      Returns:
      true if the data store contains elements that match the given Example.
    • findBy

      <S extends T, R> R findBy(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>,R> queryFunction)
      Returns entities matching the given Example applying the queryFunction that defines the query and its result type.

      The query object used with queryFunction is only valid inside the findBy(…) method call. This requires the query function to return a query result and not the FluentQuery object itself to ensure the query is executed inside the findBy(…) method.

      Parameters:
      example - must not be null.
      queryFunction - the query function defining projection, sorting, and the result type
      Returns:
      all entities matching the given Example.
      Since:
      2.6