Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

400
Views
How to use limit and skip in spring data mongodb repository?

I want query sublist in mongo collections using Spring Data MongoDB. My Code is like

public interface SomeRepo extends MongoRepository<SomeDoc, String> {
    @Query("{'field0': ?0, 'field1': ?1}, {'limit':?2, 'skip':?3}")
    List<SomeDoc> findAllByField0AndFiled1(
        Long field0,
        Long field1,
        Long limit,
        Long skip
    );
}

but limit & skip are not in Query Object

Log is Created query Document{{field0=123, field1=456}} for Document{{}} fields.

how to pass them into query object?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Thanks to @prasad_ for the answer. Using @Aggregation can solve my question.

@Aggregation("{'field0': ?0, 'field1': ?1}, {limit': ?2, 'skip': ?3}")
    List<SomeDoc> findAllByField0AndFiled1(
        Long field0,
        Long field1,
        Long limit,
        Long skip
    );
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!