0

When I wannt to use limit statement to make a business, and the consloe tell me statement error. I check the SQL statement again in MySQL command line, it's normally, such as this process: Repository Layer:

public interface VideoRepository extends JpaRepository<Video, Integer> {

    @Query(value = "select video_id, video_thumbnail_link, video_title, video_link, video_commodity_id from e_buy.video limit ?1,10", nativeQuery = true)
    List<Video> limitByIndex(String index);

}

If I visit this interface the consloe will tell me this error, but, if I change the variable of "?1,10" into "1", it works, unfortunately the only 1 reultset is not my hope.

Now i just wannt to know why JPA support "HALF LIMIT" statement rather than fully limit statement? By the way, pageable is out of order resultset to transformation data, that's a reason why i would use MyBatis rather than Pageable function.

mcry416
  • 3
  • 5
  • `LIMIT` appears to not be supported by HQL (not all SQL databases support limit). Regarding the end of your native query, I'm not sure that you can bind the limit and offset parameters using `?`. – Tim Biegeleisen Jun 12 '21 at 12:36
  • native query set true is work normaly when parameter just have one, when I use two parameters it seems awful to work. – mcry416 Jun 12 '21 at 12:47
  • It should be safe to just concatenate on the `LIMIT` clause to your query string. – Tim Biegeleisen Jun 12 '21 at 12:53

0 Answers0