title: Order By Date Desc Limit in Spring Data JPA
body: <p>I am trying to limit the query results by using Limit query. With out limit the query is working as expected. </p>
  
  <pre><code>@Query("SELECT a FROM DrmAdpodTimeSlot a where a.startTime &gt; :startTime order by a.startTime desc")
      public List&lt;DrmAdpodTimeSlot&gt; findByStartTime(@Param("startTime") Timestamp startTime);
  </code></pre>
  
  <p>But When I try to limit the records by using limit (no.of records), as follows,</p>
  
  <pre><code>@Query("SELECT a FROM DrmAdpodTimeSlot a where a.startTime &gt; :startTime order by a.startTime desc limit 2")
      public List&lt;DrmAdpodTimeSlot&gt; findByStartTime(@Param("startTime") Timestamp startTime);
  </code></pre>
  
  <p>From the above query I am getting the following error,</p>
  
  <pre><code>Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: limit near line 1, column 110 [SELECT a FROM com.dooreme.domain.DrmAd
  podTimeSlot a where a.startTime &gt; :startTime order by a.startTime desc limit 2]
  </code></pre>
  
  <p>How can I use the order by limit query in spring data jpa query?</p>