-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't use findAll(Pageable pageable) #103
Comments
Sounds like a good idea but although
works fine in a repository it seems like
does not: "org.springframework.dao.InvalidDataAccessApiUsageException: At least 1 parameter(s) provided but only 0 parameter(s) present in query" |
The problem maybe because the JpaSpecificationExecutor does only define these methods: public interface JpaSpecificationExecutor<T> {
Optional<T> findOne(@Nullable Specification<T> spec);
List<T> findAll(@Nullable Specification<T> spec);
Page<T> findAll(@Nullable Specification<T> spec, Pageable pageable);
List<T> findAll(@Nullable Specification<T> spec, Sort sort);
long count(@Nullable Specification<T> spec);
boolean exists(Specification<T> spec);
long delete(Specification<T> spec);
<S extends T, R> R findBy(Specification<T> spec, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction);
} |
I think the problem is that you cannot mix |
Yeah, that's indeed a problem! |
I don't understand why PagingAndSortingRepository does not support a findAll that returns a Slice or just a List |
Let's see if there are any comments in spring-projects/spring-data-jpa#2762 |
When using
Page<T> findAll(Pageable pageable)
Spring Data will execute the select plus the count query for every call.This can be very inefficient and in the case of a DataProvider with paging and sorting simply superfluous.
It would be better to add a custom method to the Repository like:
List<T> findBy(Pageable pageable)
to avoid the unnecessary count query.
The text was updated successfully, but these errors were encountered: