title: jpa incorrect syntax near 'limit'
body: <p>Can anybody please let me know, how can I retrieve Max value of specific column using spring data JPA.</p>
  
  <p>I have been trying with findTopByOrderByIdDesc method which has been given in spring data JPA reference document, but I am getting "incorrect syntax near 'limit' exception.   </p>
  
  <p>the method signature from spring data JPA is </p>
  
  <p>User findTopByOrderByAgeDesc();</p>
  
  <p>and I am trying to use the same method signature, here this method is not expecting any argument to pass but according to the exception where can, I pass the limit.</p>
  
  <p>even I try to change the method name as User findTop1ByOrderByIdDesc();</p>
  
  <p>but this does work.
  and I don't want to use @Query("some query")</p>
  
  <pre><code>public User getmaxSequence() {
          User user=new User();
  
          try {
              user=   userRepository.findTopByOrderByIdDesc();
  
          }catch(Exception e) {
              e.printStackTrace();
          }
  
          return user;
      }
  </code></pre>
  
  <p>when I am running the code I am getting below exception stack trace.</p>
  
  <pre><code>Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'limit'.
      at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:254)
      at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1608)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:578)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:508)
      at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)
      at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:243)
      at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:218)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:434)
      at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
      at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60)
      ... 150 more
  </code></pre>