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 Summary
Modifier and TypeMethodDescription<S extends T>
longReturns the number of instances matching the givenExample
.<S extends T>
booleanChecks whether the data store contains elements that match the givenExample
.Returns all entities matching the givenExample
.<S extends T,
R>
RfindBy
(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction) Returns entities matching the givenExample
applying thequeryFunction
that defines the query and its result type.Returns a single entity matching the givenExample
orOptional.empty()
if none was found.
-
Method Details
-
findOne
Returns a single entity matching the givenExample
orOptional.empty()
if none was found.- Parameters:
example
- must not be null.- Returns:
- a single entity matching the given
Example
orOptional.empty()
if none was found. - Throws:
IncorrectResultSizeDataAccessException
- if the Example yields more than one result.
-
findAll
Returns all entities matching the givenExample
. In case no match could be found an emptyIterable
is returned.- Parameters:
example
- must not be null.- Returns:
- all entities matching the given
Example
.
-
findAll
Returns all entities matching the givenExample
applying the givenSort
. In case no match could be found an emptyIterable
is returned.- Parameters:
example
- must not be null.sort
- theSort
specification to sort the results by, may beSort.unsorted()
, must not be null.- Returns:
- all entities matching the given
Example
. - Since:
- 1.10
-
findAll
Returns aPage
of entities matching the givenExample
. In case no match could be found, an emptyPage
is returned.- Parameters:
example
- must not be null.pageable
- the pageable to request a paged result, can bePageable.unpaged()
, must not be null.- Returns:
- a
Page
of entities matching the givenExample
.
-
count
Returns the number of instances matching the givenExample
. -
exists
Checks whether the data store contains elements that match the givenExample
. -
findBy
<S extends T,R> R findBy(Example<S> example, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction) Returns entities matching the givenExample
applying thequeryFunction
that defines the query and its result type.The query object used with
queryFunction
is only valid inside thefindBy(…)
method call. This requires the query function to return a query result and not theFluentQuery
object itself to ensure the query is executed inside thefindBy(…)
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
-