cosmos pagination is not working with latest springboot libraries

ja 26 Reputation points
2023-03-15T20:24:50.5633333+00:00
We have a springboot project which is using cosmos libraries and the pageable feature of it. It was working as expected. Now, after upgrading the springboot to 3.X.X version, the pagination feature is not working.

We always get the last 3 data even though we pass diff page.

    public interface BaseRepository extends CosmosRepository<Base, String>, CrudRepository<Base, String> {
    
        @Query("select * from c where c.base=@baseId)")
        Page<Base> findByBaseId(
            @Param("baseId") String baseId,
            Pageable pageable);
    }

This the code that we are using, it was giving expected result based on the page number passed in the Paegable object. but now, it always return the latest X number data.

This is how we are initialising the Pageable :

    PageRequest of(int page, int size, Sort sort)

I dont see any reasons why it shopped working? Any pointers?  

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,439 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Oury Ba-MSFT 16,076 Reputation points Microsoft Employee
    2023-03-15T22:28:14.6+00:00

    @ja Thank you for reaching out.

    As mentioned by Matias Quaranta https://stackoverflow.com/questions/75749614/cosmos-pagination-is-not-working-with-latest-springboot-libraries from the Azure Cosmos DB PG team.

    Currently Spring Data Cosmos does not support Spring Boot 3 or Spring Data 3 -> https://github.com/Azure/azure-sdk-for-java/issues/30458

    That is potentially the reason it is not working as expected when you migrated from 2.7.6 to 3.X (major version bump).

    Regards,

    Oury

    0 comments No comments