Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected token limit in JPA

Tags:

mysql

jpa

Whenever i'm using LIMIT in JPA query exceptionn is Thrown.can any one suggest me alternative way to filter the record on the basis of their rowNum or ronCount.

Select a from EmployeeBo where a.batchId=:'127'and LIMIT :startPonit,:endPoint,
like image 396
yogesh nautiyal Avatar asked Dec 30 '25 04:12

yogesh nautiyal


2 Answers

You can't use LIMIT in JPA Named Query, but you can restrict records up to a row count by using setMaxResult();

like image 187
Shardendu Avatar answered Jan 01 '26 18:01

Shardendu


You should use Query#setFirstResult() and Query#setMaxResults() for this.

like image 20
Predrag Maric Avatar answered Jan 01 '26 17:01

Predrag Maric



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!