List<AC_Customer> lastAC_CustomersList = session.createQuery("from AC_Customer order by customer_pk DESC LIMIT 1").list()
当我执行这个命令时,我得到了这个错误,请告诉我我的hql查询是什么。
org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:限制在第1行附近,com.softlogic.models.AC_Customer顺序中的第65列由customer_pk DESC限制1
发布于 2017-02-08 04:42:58
试着使用下面的
session.createSQLQuery("select * from AC_Customer order by customer_pk DESC LIMIT 1").list();
发布于 2022-01-20 05:18:14
HQL
不知道LIMIT
,您必须以以下方式使用setMaxResults
:
List<AC_Customer> lastAC_CustomersList = session
.createQuery("from AC_Customer order by customer_pk DESC")
.setMaxResults(1)
.getResultList()
发布于 2020-03-29 20:20:17
org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:第1行附近的偏移量,来自om.omantel.prodsheet.models.RtcsProduct的第87列,其中status=1顺序由TRACKING_ID DESC偏移1行只取下5行
@SuppressWarnings("unchecked")
@Override
public List<RtcsProduct> pagination(int page_id, int total) {
String listsql = "FROM RtcsProduct where status=1 order by TRACKING_ID DESC OFFSET "+page_id+" ROWS FETCH NEXT "+total+" ROWS ONLY";
Session session = null;
List<RtcsProduct> productlist = null;
try {
if (session == null) {
session = sessionFactory.openSession();
session.beginTransaction();
productlist = session.createQuery(listsql).list();
session.getTransaction().commit();
}
}catch(Exception ex) {
ex.printStackTrace();
}
return productlist;
}
https://stackoverflow.com/questions/37644478
复制