Interface ExecutableFindOperation.TerminatingFind<T>

All Known Subinterfaces:
ExecutableFindOperation.ExecutableFind<T>, ExecutableFindOperation.FindWithCollection<T>, ExecutableFindOperation.FindWithProjection<T>, ExecutableFindOperation.FindWithQuery<T>
Enclosing interface:
ExecutableFindOperation

public static interface ExecutableFindOperation.TerminatingFind<T>
Trigger find execution by calling one of the terminating methods.
Since:
2.0
Author:
Christoph Strobl
  • Method Summary

    Modifier and Type
    Method
    Description
    all()
    Get all matching elements.
    long
    Get the number of matching elements.
    boolean
    Check for the presence of matching elements.
    default Optional<T>
    Get the first or no result.
    Get the first or no result.
    default Optional<T>
    one()
    Get exactly zero or one result.
    Get exactly zero or one result.
    scroll(ScrollPosition scrollPosition)
    Return a window of elements either starting or resuming at ScrollPosition.
    Stream all matching elements.
  • Method Details

    • one

      default Optional<T> one()
      Get exactly zero or one result.
      Returns:
      Optional.empty() if no match found.
      Throws:
      IncorrectResultSizeDataAccessException - if more than one match found.
    • oneValue

      @Nullable T oneValue()
      Get exactly zero or one result.
      Returns:
      null if no match found.
      Throws:
      IncorrectResultSizeDataAccessException - if more than one match found.
    • first

      default Optional<T> first()
      Get the first or no result.
      Returns:
      Optional.empty() if no match found.
    • firstValue

      @Nullable T firstValue()
      Get the first or no result.
      Returns:
      null if no match found.
    • all

      List<T> all()
      Get all matching elements.
      Returns:
      never null.
    • stream

      Stream<T> stream()
      Stream all matching elements.
      Returns:
      the result Stream, containing mapped objects, needing to be closed once fully processed (e.g. through a try-with-resources clause).
    • scroll

      Window<T> scroll(ScrollPosition scrollPosition)
      Return a window of elements either starting or resuming at ScrollPosition.

      When using KeysetScrollPosition, make sure to use non-nullable sort properties as MongoDB does not support criteria to reconstruct a query result from absent document fields or null values through $gt/$lt operators.

      Parameters:
      scrollPosition - the scroll position.
      Returns:
      a window of the resulting elements.
      Since:
      4.1
      See Also:
    • count

      long count()
      Get the number of matching elements.
      This method uses an aggregation execution even for empty queries which may have an impact on performance, but guarantees shard, session and transaction compliance. In case an inaccurate count satisfies the applications needs use MongoOperations.estimatedCount(String) for empty queries instead.
      Returns:
      total number of matching elements.
    • exists

      boolean exists()
      Check for the presence of matching elements.
      Returns:
      true if at least one matching element exists.