I use Hibernate with MS SQL. Suppose I have a Car with a lot of associations, one of them being and Owner. Suppose I am interested some subset of the Cars:
getSession().createCriteria(Car.class)
.createAlias("m_owner", "owner")
.add(Restrictions.eq("m_color", "Blue")
// a lot more restrictions on Car and its associations
.addOrder(Order.asc("owner.m_lastName").ignoreCase())
.list()
I want to limit the results to 25 owners, but an owner can have multiple cars.
Is it possible to specify an offset and a limit (of 25) in the above, such that the result set contains at most 25 distinct owners?