List<AC_Customer> lastAC_CustomersList = session.createQuery("from AC_Customer order by customer_pk DESC LIMIT 1").list()
when i execute this i got this error can any one please tell me what is wron with my hql query.
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: LIMIT near line 1, column 65 [from com.softlogic.models.AC_Customer order by customer_pk DESC LIMIT 1]
try using the below
session.createSQLQuery("select * from AC_Customer order by customer_pk DESC LIMIT 1").list();
HQL
does not know LIMIT
you have to use setMaxResults
in a following way:
List<AC_Customer> lastAC_CustomersList = session
.createQuery("from AC_Customer order by customer_pk DESC")
.setMaxResults(1)
.getResultList()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With