How to select last inserted 5 record from table using JPA
with Hibernate
?
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?