[英]How to select last inserted 5 record from table using JPA with Hibernate
How to select last inserted 5 record from table using JPA
with Hibernate
? 如何使用带有
Hibernate
JPA
从表中选择最后插入的5条记录?
public List<Sample> getAgencyChangeLastFiveRecords(){
return (ArrayList<Sample>) createQuery(
"select * from ( select * from sample order by id desc) where rownum<=5 order by rownum desc"
);
}
This is not working. 这是行不通的。 What would be the corresponding
HQL
query? 相应的
HQL
查询是什么?
may be you can try below 也许你可以尝试下面
String hql="from Sample order by id desc"
Query.setMaxResults(5)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.