Class QuerydslRepositoryInvokerAdapter
java.lang.Object
org.springframework.data.querydsl.QuerydslRepositoryInvokerAdapter
- All Implemented Interfaces:
RepositoryInvocationInformation
,RepositoryInvoker
RepositoryInvoker
that is aware of a QuerydslPredicateExecutor
and Predicate
to be executed
for all flavors of findAll(…)
. All other calls are forwarded to the configured delegate.- Author:
- Oliver Gierke
-
Constructor Summary
ConstructorDescriptionQuerydslRepositoryInvokerAdapter
(RepositoryInvoker delegate, QuerydslPredicateExecutor<Object> executor, com.querydsl.core.types.Predicate predicate) Creates a newQuerydslRepositoryInvokerAdapter
for the given delegateRepositoryInvoker
,QuerydslPredicateExecutor
and QuerydslPredicate
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the repository has a method to delete objects.boolean
Returns whether the repository has a method to find all objects.boolean
Returns whether the repository has a method to find a single object.boolean
Returns whether the repository has a method to save objects.void
Invokes the method equivalent toCrudRepository.deleteById(Object)
.invokeFindAll
(Pageable pageable) Invokes the find-all method of the underlying repository using the method taking aPageable
as parameter if available (i.e. the equivalent toPagingAndSortingRepository.findAll(Pageable)
), using the method taking aSort
if available (i.e. the equivalent toPagingAndSortingRepository.findAll(Sort)
by extracting theSort
contained in the givenPageable
) or the plain equivalent toCrudRepository.findAll()
.invokeFindAll
(Sort sort) Invokes the find-all method of the underlying repository using the method taking aSort
as parameter if available (i.e. the equivalent toPagingAndSortingRepository.findAll(Sort)
) or the plain equivalent toCrudRepository.findAll()
.<T> Optional<T>
invokeFindById
(Object id) Invokes the method equivalent toCrudRepository.findById(Object)
.invokeQueryMethod
(Method method, MultiValueMap<String, ? extends Object> parameters, Pageable pageable, Sort sort) <T> T
invokeSave
(T object) Invokes the method equivalent toCrudRepository.save(Object)
on the repository.
-
Constructor Details
-
QuerydslRepositoryInvokerAdapter
public QuerydslRepositoryInvokerAdapter(RepositoryInvoker delegate, QuerydslPredicateExecutor<Object> executor, com.querydsl.core.types.Predicate predicate) Creates a newQuerydslRepositoryInvokerAdapter
for the given delegateRepositoryInvoker
,QuerydslPredicateExecutor
and QuerydslPredicate
.- Parameters:
delegate
- must not be null.executor
- must not be null.predicate
- must not be null.
-
-
Method Details
-
invokeFindAll
Description copied from interface:RepositoryInvoker
Invokes the find-all method of the underlying repository using the method taking aPageable
as parameter if available (i.e. the equivalent toPagingAndSortingRepository.findAll(Pageable)
), using the method taking aSort
if available (i.e. the equivalent toPagingAndSortingRepository.findAll(Sort)
by extracting theSort
contained in the givenPageable
) or the plain equivalent toCrudRepository.findAll()
.- Specified by:
invokeFindAll
in interfaceRepositoryInvoker
- Parameters:
pageable
- must not be null.- Returns:
- the result of the invocation of the find-all method.
-
invokeFindAll
Description copied from interface:RepositoryInvoker
Invokes the find-all method of the underlying repository using the method taking aSort
as parameter if available (i.e. the equivalent toPagingAndSortingRepository.findAll(Sort)
) or the plain equivalent toCrudRepository.findAll()
.- Specified by:
invokeFindAll
in interfaceRepositoryInvoker
- Parameters:
sort
- must not be null.- Returns:
- the result of the invocation of the find-all method.
-
hasDeleteMethod
public boolean hasDeleteMethod()Description copied from interface:RepositoryInvocationInformation
Returns whether the repository has a method to delete objects.- Specified by:
hasDeleteMethod
in interfaceRepositoryInvocationInformation
- Returns:
-
hasFindAllMethod
public boolean hasFindAllMethod()Description copied from interface:RepositoryInvocationInformation
Returns whether the repository has a method to find all objects.- Specified by:
hasFindAllMethod
in interfaceRepositoryInvocationInformation
- Returns:
-
hasFindOneMethod
public boolean hasFindOneMethod()Description copied from interface:RepositoryInvocationInformation
Returns whether the repository has a method to find a single object.- Specified by:
hasFindOneMethod
in interfaceRepositoryInvocationInformation
- Returns:
-
hasSaveMethod
public boolean hasSaveMethod()Description copied from interface:RepositoryInvocationInformation
Returns whether the repository has a method to save objects.- Specified by:
hasSaveMethod
in interfaceRepositoryInvocationInformation
- Returns:
-
invokeDeleteById
Description copied from interface:RepositoryInvoker
Invokes the method equivalent toCrudRepository.deleteById(Object)
. The given id is assumed to be of a type convertible into the actual identifier type of the backing repository.- Specified by:
invokeDeleteById
in interfaceRepositoryInvoker
- Parameters:
id
- must not be null.
-
invokeFindById
Description copied from interface:RepositoryInvoker
Invokes the method equivalent toCrudRepository.findById(Object)
.- Specified by:
invokeFindById
in interfaceRepositoryInvoker
- Parameters:
id
- must not be null.- Returns:
- the entity with the given id.
-
invokeQueryMethod
public Optional<Object> invokeQueryMethod(Method method, MultiValueMap<String, ? extends Object> parameters, Pageable pageable, Sort sort) Description copied from interface:RepositoryInvoker
- Specified by:
invokeQueryMethod
in interfaceRepositoryInvoker
- Parameters:
method
- must not be null.parameters
- must not be null.pageable
- must not be null.sort
- must not be null.- Returns:
- the result of the invoked query method.
-
invokeSave
public <T> T invokeSave(T object) Description copied from interface:RepositoryInvoker
Invokes the method equivalent toCrudRepository.save(Object)
on the repository.- Specified by:
invokeSave
in interfaceRepositoryInvoker
- Returns:
- the result of the invocation of the save method
-