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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
count(PredicateSpecification<T> spec)
Returns the number of instances that the givenQuerySpecification
will return.long
count(QuerySpecification<T> spec)
Returns the number of instances that the givenQuerySpecification
will return.long
deleteAll(CriteriaDeleteBuilder<T> builder)
Delete all entities using build criteria query.long
deleteAll(DeleteSpecification<T> spec)
Deletes all entities matching the givenDeleteSpecification
.long
deleteAll(PredicateSpecification<T> spec)
Deletes all entities matching the givenPredicateSpecification
.<R> java.util.List<R>
findAll(CriteriaQueryBuilder<R> builder)
Find all using build criteria query.java.util.List<T>
findAll(PredicateSpecification<T> spec)
Returns all entities matching the givenPredicateSpecification
.Page<T>
findAll(PredicateSpecification<T> spec, Pageable pageable)
Returns aPage
of entities matching the givenQuerySpecification
.java.util.List<T>
findAll(PredicateSpecification<T> spec, Sort sort)
Returns all entities matching the givenQuerySpecification
andSort
.java.util.List<T>
findAll(QuerySpecification<T> spec)
Returns all entities matching the givenQuerySpecification
.Page<T>
findAll(QuerySpecification<T> spec, Pageable pageable)
Returns aPage
of entities matching the givenQuerySpecification
.java.util.List<T>
findAll(QuerySpecification<T> spec, Sort sort)
Returns all entities matching the givenQuerySpecification
andSort
.<R> R
findOne(CriteriaQueryBuilder<R> builder)
Find one using build criteria query.java.util.Optional<T>
findOne(PredicateSpecification<T> spec)
Returns a single entity matching the givenPredicateSpecification
.java.util.Optional<T>
findOne(QuerySpecification<T> spec)
Returns a single entity matching the givenQuerySpecification
.long
updateAll(CriteriaUpdateBuilder<T> builder)
Updates all entities using build criteria query.long
updateAll(UpdateSpecification<T> spec)
Updates all entities matching the givenUpdateSpecification
.
-
-
-
Method Detail
-
findOne
java.util.Optional<T> findOne(@Nullable QuerySpecification<T> spec)
Returns a single entity matching the givenQuerySpecification
.- Parameters:
spec
- The query specification- Returns:
- optional found result
-
findOne
java.util.Optional<T> findOne(@Nullable PredicateSpecification<T> spec)
Returns a single entity matching the givenPredicateSpecification
.- Parameters:
spec
- The query specification- Returns:
- optional found result
-
findAll
@NonNull java.util.List<T> findAll(@Nullable QuerySpecification<T> spec)
Returns all entities matching the givenQuerySpecification
.- Parameters:
spec
- The query specification- Returns:
- found results
-
findAll
@NonNull java.util.List<T> findAll(@Nullable PredicateSpecification<T> spec)
Returns all entities matching the givenPredicateSpecification
.- Parameters:
spec
- The query specification- Returns:
- found results
-
findAll
@NonNull Page<T> findAll(@Nullable QuerySpecification<T> spec, Pageable pageable)
Returns aPage
of entities matching the givenQuerySpecification
.- Parameters:
spec
- The query specificationpageable
- The pageable object- Returns:
- a page
-
findAll
@NonNull Page<T> findAll(@Nullable PredicateSpecification<T> spec, Pageable pageable)
Returns aPage
of entities matching the givenQuerySpecification
.- Parameters:
spec
- The query specificationpageable
- The pageable object- Returns:
- a page
-
findAll
@NonNull java.util.List<T> findAll(@Nullable QuerySpecification<T> spec, Sort sort)
Returns all entities matching the givenQuerySpecification
andSort
.- Parameters:
spec
- The query specificationsort
- The sort object- Returns:
- found results
-
findAll
@NonNull java.util.List<T> findAll(@Nullable PredicateSpecification<T> spec, Sort sort)
Returns all entities matching the givenQuerySpecification
andSort
.- Parameters:
spec
- The query specificationsort
- The sort object- Returns:
- found results
-
findAll
@NonNull <R> java.util.List<R> findAll(@Nullable CriteriaQueryBuilder<R> builder)
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
@NonNull <R> R findOne(@Nullable CriteriaQueryBuilder<R> builder)
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
long count(@Nullable QuerySpecification<T> spec)
Returns the number of instances that the givenQuerySpecification
will return.- Parameters:
spec
- The query specification- Returns:
- the number of instances.
-
count
long count(@Nullable PredicateSpecification<T> spec)
Returns the number of instances that the givenQuerySpecification
will return.- Parameters:
spec
- The query specification- Returns:
- the number of instances.
-
deleteAll
long deleteAll(@Nullable DeleteSpecification<T> spec)
Deletes all entities matching the givenDeleteSpecification
.- Parameters:
spec
- The delete specification- Returns:
- the number records deleted.
-
deleteAll
long deleteAll(@Nullable PredicateSpecification<T> spec)
Deletes all entities matching the givenPredicateSpecification
.- Parameters:
spec
- The delete specification- Returns:
- the number records deleted.
-
deleteAll
long deleteAll(@Nullable CriteriaDeleteBuilder<T> builder)
Delete all entities using build criteria query.- Parameters:
builder
- The delete criteria query builder- Returns:
- the number records updated.
- Since:
- 3.5.0
-
updateAll
long updateAll(@Nullable UpdateSpecification<T> spec)
Updates all entities matching the givenUpdateSpecification
.- Parameters:
spec
- The update specification- Returns:
- the number records updated.
-
updateAll
long updateAll(@Nullable CriteriaUpdateBuilder<T> builder)
Updates all entities using build criteria query.- Parameters:
builder
- The update criteria query builder- Returns:
- the number records updated.
- Since:
- 3.5.0
-
-