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 TypeMethodDescriptionall()
Get all matching elements.long
count()
Get the number of matching elements.boolean
exists()
Check for the presence of matching elements.first()
Get the first or no result.Get the first or no result.one()
Get exactly zero or one result.oneValue()
Get exactly zero or one result.scroll
(ScrollPosition scrollPosition) Return a window of elements either starting or resuming atScrollPosition
.stream()
Stream all matching elements.
-
Method Details
-
one
Get exactly zero or one result.- Returns:
Optional.empty()
if no match found.- Throws:
IncorrectResultSizeDataAccessException
- if more than one match found.
-
oneValue
Get exactly zero or one result.- Returns:
- null if no match found.
- Throws:
IncorrectResultSizeDataAccessException
- if more than one match found.
-
first
Get the first or no result.- Returns:
Optional.empty()
if no match found.
-
firstValue
Get the first or no result.- Returns:
- null if no match found.
-
all
Get all matching elements.- Returns:
- never null.
-
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
Return a window of elements either starting or resuming atScrollPosition
.When using
KeysetScrollPosition
, make sure to use non-nullablesort properties
as MongoDB does not support criteria to reconstruct a query result from absent document fields ornull
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 anaggregation execution
even for emptyqueries
which may have an impact on performance, but guarantees shard, session and transaction compliance. In case an inaccurate count satisfies the applications needs useMongoOperations.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.
-