문제

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.

도움이 되었습니까?

해결책

Shouldn't QueryDslPredicateExecutor.findAll(Predicate predicate, Pageable pageable) do the trick for you? You could hand in a new PageRequest(0, limit) and thus would get back the first limitresults.

다른 팁

How about using the MIN and MAX function to attain this.

SELECT MAX(objDate) FROM Object
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top