Hibernate version:
Hibernate 3.1 beta 3
I'm trying to find a more efficient version of paging a collection from an entity. Current method is like this:
Code:
// The entity we get the un-initalized collection from
List queue = container.getQueue();
getSession().createFilter(queue, "").setFirstResult(0).setMaxResults(10);
Unfortunately this doen't allow us to join without resorting to sql using this method.
Ideally we could have a method such as:
Code:
// The entity we get the un-initalized collection from
Collection queue = container.getQueue();
getSession().createCriteria(queue).addJoin().setFetchMode("someProperty", FetchMode.JOIN).setFirstResult(0).setFetchSize(10);
However as this is not avaliable, then way that we are currently doing this is:
Code:
// The entity we get the un-initalized collection from
Collection queue = container.getQueue();
getSession().createFilter(queue, "").setFirstResult(0).setMaxResults(10);
// for each of the entries, call Hibernate.initalize(subProperty);
As we have a lot of properties which need to be fetched for each of the elements in the queue, this is a higly inefficient method.
If anyone has any thoughs on this they would be very helpful.
Matt.
[/code]