Reputation: 161
I want to find the highest-value id in my entity table. Reading through other posts I found you can construct query methods such as:
public interface ArticleRepository extends CrudRepository<Article, Integer> {
public List<Article> findByOrderByIdDesc();
}
These method gets constructed out of keyword modules, and I saw someone else had made one that returned the top 10 results only. I'd like to find a listing of the base keywords, so I can try to optimize the call (it seems to be running a bit slow). I don't know if it will help, but I'd first like to try something like findFirstByOrderByIdDesc()
Upvotes: 0
Views: 38
Reputation: 606
the documentation is in Spring Data JPA: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods and I see the FindFirst mentioned here: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repository-query-keywords
For your needs, how about findFirst5OrderByIdDesc()?
Upvotes: 1