Closed as not planned
Description
I am using SpringBoot-Starter-Data-JPA-Version: 3.3.3
. When I use Page<T> findAll(@Nullable Specification<T> spec, Pageable pageable)
, I will get 2 queries. The first query is correct, but the second query, with it's use to count total elements was missing a condition..
The first query SQL result:
select distinct w1_0.id, w1_0.auth0_role, w1_0.contract_id, w1_0.contractor_admin_id, w1_0.contractor_name, w1_0.contractor_project_manager_id, w1_0.contractor_safety_personnel_id, w1_0.cover_sppo_id, w1_0.cover_supervisor_id, w1_0.created_at, w1_0.created_by, w1_0.description, w1_0.end_work_date_time, w1_0.is_deleted, w1_0.is_on_premise, w1_0.latitude, w1_0.location, w1_0.longitude, w1_0.section_id, w1_0.sppo_id, w1_0.start_work_date_time, w1_0.status, w1_0.supervisor_id, w1_0.updated_at, w1_0.zone from worksite w1_0 where ( w1_0.is_deleted = false ) and w1_0.status in (?, ?, ?, ?) and ( w1_0.contract_id in ((select distinct cs3_0.contract_id from contract_sppo cs3_0 where cs3_0.sppo_id=?)) or w1_0.sppo_id=? or w1_0.cover_sppo_id=? ) order by w1_0.created_at desc offset ? rows fetch first ? rows only
The second query, use to count total elements result:
select distinct count(distinct w1_0.id) from worksite w1_0 where ( w1_0.is_deleted = false ) and ( w1_0.contract_id in ((select distinct cs1_0.contract_id from contract_sppo cs1_0 where cs1_0.sppo_id=?)) or w1_0.sppo_id=? or w1_0.cover_sppo_id=? )
The condition and w1_0.status in (?, ?, ?, ?)
was missing in the countQuery
So when I try to use findAll() to pageable will get incorrect result.
Metadata
Metadata
Assignees
Labels
No labels