title: How to add dynamic sql query in JPA query annotation in spring boot?
body: <p>I want to add a sorting column in the query at run time. I have used query annotation for build query. I have used param "sortCol" for adding a sort column in the query. But somehow query annotation not recognize the "sortCol" parma and hence not using it. Not giving any error as well.</p>
  
  <pre><code> SELECT
          * 
      FROM
          request r 
      WHERE
          r.asset_type IN (
              ?, ?, ?
          ) 
          AND r.request_type IN (
              ?, ?
          ) 
          AND r.status IN  (
              ?, ?, ?, ?
          ) 
          AND r.assign_to = ?  
          AND (
              r.request_custom_id LIKE ? 
              OR r.project_name LIKE ? 
              OR r.asset_type LIKE ? 
              OR r.request_type LIKE ? 
          ) 
      ORDER BY
          ? limit ?"
  </code></pre>
  
  <p>In this after the order by column name is missing, which I have added. At the run time:</p>
  
  <pre><code>    @Query(value ="SELECT * FROM request r WHERE r.asset_type IN (:assetType) AND r.request_type IN (:requestType) AND r.status IN  (:statusList) AND r.assign_to = :assignTo  AND ( r.request_custom_id LIKE %:searchTerm% OR r.project_name LIKE %:searchTerm1% OR r.asset_type LIKE %:searchTerm2% OR r.request_type LIKE %:searchTerm3% ) ORDER BY :sort",nativeQuery = true)
      Page&lt;Request&gt; findRequestdata(Pageable pageable,
              @Param("assetType") List&lt;String&gt; assetType,
              @Param("requestType") List&lt;String&gt; requestType,
              @Param("statusList") List&lt;Integer&gt; statusList,
              @Param("assignTo") Long assignTo,
              @Param("searchTerm") String searchTerm,
              @Param("searchTerm1") String searchTerm1,
              @Param("searchTerm2") String searchTerm2,
              @Param("searchTerm3") String searchTerm3,
              @Param("sort") String sortCol);
  </code></pre>
  
  <p>All parma is setting properly except "sortCol".
  Please suggest where am missing anything.</p>