Package io.micronaut.data.repository.jpa
Interface JpaSpecificationExecutor<T>
- Type Parameters:
T- The entity type
public interface JpaSpecificationExecutor<T>
Interface to allow execution of query/delete/update methods using dynamic JPA criteria API.
Based on Spring Data's 'org.springframework.data.jpa.repository.JpaSpecificationExecutor'.
- Since:
- 3.2
- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescriptionlongcount(PredicateSpecification<T> spec) Returns the number of instances that the givenQuerySpecificationwill return.longcount(QuerySpecification<T> spec) Returns the number of instances that the givenQuerySpecificationwill return.longdeleteAll(CriteriaDeleteBuilder<T> builder) Delete all entities using build criteria query.longdeleteAll(DeleteSpecification<T> spec) Deletes all entities matching the givenDeleteSpecification.longdeleteAll(PredicateSpecification<T> spec) Deletes all entities matching the givenPredicateSpecification.booleanexists(PredicateSpecification<T> spec) Returns whether an instance was found for the givenPredicateSpecification.booleanexists(QuerySpecification<T> spec) Returns whether an instance was found for the givenQuerySpecification.<R> List<R>findAll(CriteriaQueryBuilder<R> builder) Find all using build criteria query.findAll(PredicateSpecification<T> spec) Returns all entities matching the givenPredicateSpecification.findAll(PredicateSpecification<T> spec, Pageable pageable) Returns aPageof entities matching the givenQuerySpecification.findAll(PredicateSpecification<T> spec, Sort sort) Returns all entities matching the givenQuerySpecificationandSort.findAll(QuerySpecification<T> spec) Returns all entities matching the givenQuerySpecification.findAll(QuerySpecification<T> spec, Pageable pageable) Returns aPageof entities matching the givenQuerySpecification.findAll(QuerySpecification<T> spec, Sort sort) Returns all entities matching the givenQuerySpecificationandSort.<R> RfindOne(CriteriaQueryBuilder<R> builder) Find one using build criteria query.findOne(PredicateSpecification<T> spec) Returns a single entity matching the givenPredicateSpecification.findOne(QuerySpecification<T> spec) Returns a single entity matching the givenQuerySpecification.longupdateAll(CriteriaUpdateBuilder<T> builder) Updates all entities using build criteria query.longupdateAll(UpdateSpecification<T> spec) Updates all entities matching the givenUpdateSpecification.
-
Method Details
-
findOne
Returns a single entity matching the givenQuerySpecification.- Parameters:
spec- The query specification- Returns:
- optional found result
-
findOne
Returns a single entity matching the givenPredicateSpecification.- Parameters:
spec- The query specification- Returns:
- optional found result
-
findAll
Returns all entities matching the givenQuerySpecification.- Parameters:
spec- The query specification- Returns:
- found results
-
findAll
Returns all entities matching the givenPredicateSpecification.- Parameters:
spec- The query specification- Returns:
- found results
-
findAll
Returns aPageof entities matching the givenQuerySpecification.- Parameters:
spec- The query specificationpageable- The pageable object- Returns:
- a page
-
findAll
Returns aPageof entities matching the givenQuerySpecification.- Parameters:
spec- The query specificationpageable- The pageable object- Returns:
- a page
-
findAll
Returns all entities matching the givenQuerySpecificationandSort.- Parameters:
spec- The query specificationsort- The sort object- Returns:
- found results
-
findAll
Returns all entities matching the givenQuerySpecificationandSort.- Parameters:
spec- The query specificationsort- The sort object- Returns:
- found results
-
findAll
Find all using build criteria query.- Type Parameters:
R- the result type- Parameters:
builder- The criteria query builder- Returns:
- the number records updated.
- Since:
- 3.5.0
-
findOne
Find one using build criteria query.- Type Parameters:
R- the result type- Parameters:
builder- The criteria query builder- Returns:
- the number records updated.
- Since:
- 3.5.0
-
count
Returns the number of instances that the givenQuerySpecificationwill return.- Parameters:
spec- The query specification- Returns:
- the number of instances.
-
count
Returns the number of instances that the givenQuerySpecificationwill return.- Parameters:
spec- The query specification- Returns:
- the number of instances.
-
exists
Returns whether an instance was found for the givenQuerySpecification.- Parameters:
spec- The query specification- Returns:
- the number of instances.
- Since:
- 3.8
-
exists
Returns whether an instance was found for the givenPredicateSpecification.- Parameters:
spec- The query specification- Returns:
- the number of instances.
- Since:
- 3.8
-
deleteAll
Deletes all entities matching the givenDeleteSpecification.- Parameters:
spec- The delete specification- Returns:
- the number records deleted.
-
deleteAll
Deletes all entities matching the givenPredicateSpecification.- Parameters:
spec- The delete specification- Returns:
- the number records deleted.
-
deleteAll
Delete all entities using build criteria query.- Parameters:
builder- The delete criteria query builder- Returns:
- the number records updated.
- Since:
- 3.5.0
-
updateAll
Updates all entities matching the givenUpdateSpecification.- Parameters:
spec- The update specification- Returns:
- the number records updated.
-
updateAll
Updates all entities using build criteria query.- Parameters:
builder- The update criteria query builder- Returns:
- the number records updated.
- Since:
- 3.5.0
-