Results 1 to 3 of 3

Thread: How to use order by and Limit in Spring Data JPA using QueryDSL

  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Default How to use order by and Limit in Spring Data JPA using QueryDSL

    I am using Spring Data JPA with a RDBMS in my project. I have a requirement where I have to fetch a single record from the Database from a table which has the latest date. For this I need to use a limit and order by function OR using sub queries. However, I wished to know if i wish for not to use NamedQuery is there a way I can achieve this using Spring Data JPA and QueryDSL.

  2. #2
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    Have a look at QueryDslPredicateExecuter.findAll(Predicate predicate, Pageable pageable). The Pageable (PageRequest is the implementation class you'll want to hand in) allows narrowing down the result set.

  3. #3
    Join Date
    Oct 2009
    Posts
    2

    Default Thanks

    Quote Originally Posted by Oliver Gierke View Post
    Have a look at QueryDslPredicateExecuter.findAll(Predicate predicate, Pageable pageable). The Pageable (PageRequest is the implementation class you'll want to hand in) allows narrowing down the result set.
    Thanks. It worked.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •