I know we use query.setMaxResults() to put a limit in HQL, but how about when I need two limits in a query.
For instance:
Select t from Table as t where t.id = 1 and t.date > (Select t2.date from Table as t2 where t2.id = 2 order by date desc limit 1) order by date desc limit 1;
If I put query.setMaxResults(1), it will be applied on the outer select, but how should I apply it in inner select statement?
Thanks
This is simply something that neither Hibernate nor JPA as a standard support through their various Criteria-based APIs and their HQL/JPQL string-based APIs.
You can however still use Native SQL to do this.