Skip to content

DATAJDBC-531 - Skip COUNT Query If Page Query result totalPage is 1. #211

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jdbc.core.convert.DataAccessStrategy;
Expand All @@ -39,6 +38,7 @@
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.event.*;
import org.springframework.data.support.PageableExecutionUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

Expand All @@ -50,6 +50,7 @@
* @author Thomas Lang
* @author Christoph Strobl
* @author Milan Milanov
* @author Myeonghyeon Lee
*/
public class JdbcAggregateTemplate implements JdbcAggregateOperations {

Expand Down Expand Up @@ -248,10 +249,9 @@ public <T> Page<T> findAll(Class<T> domainType, Pageable pageable) {
Assert.notNull(domainType, "Domain type must not be null!");

Iterable<T> items = triggerAfterLoad(accessStrategy.findAll(domainType, pageable));
long totalCount = accessStrategy.count(domainType);
List<T> content = StreamSupport.stream(items.spliterator(), false).collect(Collectors.toList());

return new PageImpl<>(StreamSupport.stream(items.spliterator(), false).collect(Collectors.toList()), pageable,
totalCount);
return PageableExecutionUtils.getPage(content, pageable, () -> accessStrategy.count(domainType));
}

/*
Expand Down