Hi,
I'm facing the following problem:
Class A owns a set (called "entries) and now I want to limit the size of the set when querying the Class. E.g. if the set has 20 entries in the database, I want to be able to retrieve only record 15 to 17. I tried it with the following, but the setFirstResult (and setMaxResults) applies for the class and not for the entries (as you see am using the Spring hibernatetemplate):
Code:
final List<A> list = getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Criteria criteria = session.createCriteria(A.class, "a");
Criteria subCriteria = criteria.createCriteria("a.entries"); // tried both "entries" and "a.entries"
subCriteria.setFirstResult(first).setMaxResults(count); // first and count are regular ints
return criteria.list();
}
});
thanks for your help!