What is the LIMIT clause alternative in JPQL?
问题 I'm working with PostgreSQL query implementing in JPQL. This is a sample native psql query which works fine, SELECT * FROM students ORDER BY id DESC LIMIT 1; The same query in JPQL doesnt work, @Query("SELECT s FROM Students s ORDER BY s.id DESC LIMIT 1") Students getLastStudentDetails(); seems like LIMIT clause doesn't work in JPQL. According to JPA documentation we can use setMaxResults/setFirstResult , Can anyone tell me how can I use that in my above query? 回答1: You are using JPQL which