Order by not getting appended properly in spring jpa

@Query(value = """
            WITH
            cte1 as (
                select distinct
                    woa.id as woa_id
                from
                    work_activity woa
                join activity_assignment waa on waa.activity_id = woa.id
                join activity_assignment_log waal on waal.activity_id = woa.id
                join ref_provider rp on rp.id = waal.provider_id
                where
                    rp.external_id in (:providerIds)
                    and
                    woa.modified_date >= CAST(:modifiedDate AS timestamp)
            )
            select *
            from (
                select wa.id as waId, wa.alternate_id as waAltId, wo.id as woId,
                wo.alternate_id as woAltId, rr.alternate_id as rrAltId,
                wa.description as waDesc, rs.alternate_id as waStatus, wa.eta_start as waEtaStart,
                sl_c.target_date as sle, rot.description as serviceLineDesc,
                (SELECT ro.org_value from ref_organization ro join ref_org_structure ros on ro.structure_id = ros.id where ro.id = any(wo.orgs)
                and ros.structure_name = 'Customer') AS customer,
                (SELECT ro.org_value from ref_organization ro join ref_org_structure ros on ro.structure_id = ros.id where ro.id = any(wo.orgs)
                and ros.structure_name = 'Country') AS country,
                wa.asset_id as assetId, wa.location_id as locationId,
                wa.created_date as createdDate, wa.status_id as statusId,
                rr.id as requestId, sl_c.target_date as targetCompleteDate,
                sl_a.target_date as targetAttendDate, sl_r.target_date as targetRespondDate,
                wa.sequence as sequence,
                (select change_date from activity_status_log asl join ref_status rs on asl.status_id = rs.id
                where activity_id = wa.id and rs.alternate_id = 'IN_PROGRESS'
                order by asl.change_date desc
                limit 1) as actualStartDate,
                rr.priority,
                rp.external_id as providerId,
                ROW_NUMBER() OVER(PARTITION BY aal.activity_id ORDER BY aal.created_date DESC) as rn,
                wa.modified_date as modifiedDate,
                rsc.input_stream_name as sourceChannel
                from work_activity wa
                join work_order wo on wa.work_order_id = wo.id
                join work_assembly wa2 on wo.work_assembly_id = wa2.id
                join ref_request rr on wa2.request_id = rr.id
                join ref_status rs on wa.status_id = rs.id
                join activity_assignment_log aal on wa.id = aal.activity_id
                join activity_assignment aa on aa.activity_id = aal.activity_id and aa.assignee = aal.provider_id
                join ref_provider rp ON aal.provider_id = rp.id
                left join ref_service_classification rsc on rsc.id = rr.service_classification_id
                left join sla_log sl_c on wa.id = sl_c.activity_id and sl_c."name" = 'COMPLETE'
                left join sla_log sl_a on wa.id = sl_a.activity_id and sl_a."name" = 'ATTEND'
                left join sla_log sl_r on wa.id = sl_r.activity_id and sl_r."name" = 'RESPOND'
                left join ref_object_translation rot on wa.service_line_id = rot.object_id
            ) as oa
            JOIN cte1 ON cte1.woa_id = oa.waId
            where ((oa.rn = 1 and oa.providerId in (:providerIds) and oa.sle between now() and now() + interval '3 days')
                or (oa.rn = 1 and oa.providerId in (:providerIds) and oa.targetCompleteDate between now() - interval '3 days' and now())
                or (oa.rn = 1 and oa.providerId in (:providerIds) and oa.waStatus in ('IN_PROGRESS','ON_HOLD'))
                or (oa.rn = 1 and oa.providerId NOT in (:providerIds))
                )
                and oa.modifiedDate >= CAST(:modifiedDate AS timestamp)
        """
        , countQuery = """
            WITH
            cte1 as (
                select distinct
                    woa.id as woa_id
                from
                    work_activity woa
                join activity_assignment waa on waa.activity_id = woa.id
                join activity_assignment_log waal on waal.activity_id = woa.id
                join ref_provider rp on rp.id = waal.provider_id
                where
                    rp.external_id in (:providerIds)
                    and
                    woa.modified_date >= CAST(:modifiedDate AS timestamp)
            )
            select count(*)
            from (
                select wa.id as waId, wa.alternate_id as waAltId, wo.id as woId,
                wo.alternate_id as woAltId, rr.alternate_id as rrAltId,
                wa.description as waDesc, rs.alternate_id as waStatus, wa.eta_start as waEtaStart,
                sl_c.target_date as sle, rot.description as serviceLineDesc,
                (SELECT ro.org_value from ref_organization ro join ref_org_structure ros on ro.structure_id = ros.id where ro.id = any(wo.orgs)
                and ros.structure_name = 'Customer') AS customer,
                (SELECT ro.org_value from ref_organization ro join ref_org_structure ros on ro.structure_id = ros.id where ro.id = any(wo.orgs)
                and ros.structure_name = 'Country') AS country,
                wa.asset_id as assetId, wa.location_id as locationId,
                wa.created_date as createdDate, wa.status_id as statusId,
                rr.id as requestId, sl_c.target_date as targetCompleteDate,
                sl_a.target_date as targetAttendDate, sl_r.target_date as targetRespondDate,
                wa.sequence as sequence,
                (select change_date from activity_status_log asl join ref_status rs on asl.status_id = rs.id
                where activity_id = wa.id and rs.alternate_id = 'IN_PROGRESS'
                order by asl.change_date desc
                limit 1) as actualStartDate,
                rp.external_id as providerId,
                ROW_NUMBER() OVER(PARTITION BY aal.activity_id ORDER BY aal.created_date DESC) as rn,
                wa.modified_date as modifiedDate,
                rsc.input_stream_name as sourceChannel
                from work_activity wa
                join work_order wo on wa.work_order_id = wo.id
                join work_assembly wa2 on wo.work_assembly_id = wa2.id
                join ref_request rr on wa2.request_id = rr.id
                join ref_status rs on wa.status_id = rs.id
                join activity_assignment_log aal on wa.id = aal.activity_id
                join activity_assignment aa on aa.activity_id = aal.activity_id and aa.assignee = aal.provider_id
                join ref_provider rp ON aal.provider_id = rp.id
                left join ref_service_classification rsc on rsc.id = rr.service_classification_id
                left join sla_log sl_c on wa.id = sl_c.activity_id and sl_c."name" = 'COMPLETE'
                left join sla_log sl_a on wa.id = sl_a.activity_id and sl_a."name" = 'ATTEND'
                left join sla_log sl_r on wa.id = sl_r.activity_id and sl_r."name" = 'RESPOND'
                left join ref_object_translation rot on wa.service_line_id = rot.object_id
            ) as oa
            JOIN cte1 ON cte1.woa_id = oa.waId
            where ((oa.rn = 1 and oa.providerId in (:providerIds) and oa.sle between now() and now() + interval '3 days')
                or (oa.rn = 1 and oa.providerId in (:providerIds) and oa.targetCompleteDate between now() - interval '3 days' and now())
                or (oa.rn = 1 and oa.providerId in (:providerIds) and oa.waStatus in ('IN_PROGRESS','ON_HOLD'))
                or (oa.rn = 1 and oa.providerId NOT in (:providerIds))
                )
                and oa.modifiedDate >= CAST(:modifiedDate AS timestamp)
        """, nativeQuery = true)
Page<ActivityViewResult> findAllOfflineActivitiesForProvider(Pageable pageable, @Param("providerIds") List<UUID> providerIds, @Param("modifiedDate") String modifiedDate);

Here in the above query..

the pageable object’s sort by is not getting appended..

it is instead appending , instead of order by

if i remove the order by in Row_Number section, then order by is getting appended correctly..

Any workaround or solution would be greatly appreciated
I have tried a lot but dont have a working query

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật