Interface JpaSpecificationExecutor<T>
- All Known Subinterfaces:
JpaRepositoryImplementation<T,
ID>
- All Known Implementing Classes:
QuerydslJpaRepository
,SimpleJpaRepository
public interface JpaSpecificationExecutor<T>
Interface to allow execution of
Specification
s based on the JPA criteria API.- Author:
- Oliver Gierke, Christoph Strobl, Diego Krupitza
-
Method Summary
Modifier and TypeMethodDescriptionlong
count
(Specification<T> spec) Returns the number of instances that the givenSpecification
will return.boolean
exists
(Specification<T> spec) Checks whether the data store contains elements that match the givenSpecification
.findAll
(Specification<T> spec) Returns all entities matching the givenSpecification
.findAll
(Specification<T> spec, Pageable pageable) Returns aPage
of entities matching the givenSpecification
.findAll
(Specification<T> spec, Sort sort) Returns all entities matching the givenSpecification
andSort
.findOne
(Specification<T> spec) Returns a single entity matching the givenSpecification
orOptional.empty()
if none found.
-
Method Details
-
findOne
Returns a single entity matching the givenSpecification
orOptional.empty()
if none found.- Parameters:
spec
- can be null.- Returns:
- never null.
- Throws:
IncorrectResultSizeDataAccessException
- if more than one entity found.
-
findAll
Returns all entities matching the givenSpecification
.- Parameters:
spec
- can be null.- Returns:
- never null.
-
findAll
Returns aPage
of entities matching the givenSpecification
.- Parameters:
spec
- can be null.pageable
- must not be null.- Returns:
- never null.
-
findAll
Returns all entities matching the givenSpecification
andSort
.- Parameters:
spec
- can be null.sort
- must not be null.- Returns:
- never null.
-
count
Returns the number of instances that the givenSpecification
will return.- Parameters:
spec
- theSpecification
to count instances for. Can be null.- Returns:
- the number of instances.
-
exists
Checks whether the data store contains elements that match the givenSpecification
.- Parameters:
spec
- theSpecification
to use for the existence check. Must not be null.- Returns:
true
if the data store contains elements that match the givenSpecification
otherwisefalse
.
-