Hi,
I'm using Hibernate for a while and I find it the best ORM solution I've ever seen.
Now I'm facing the following problem: in my code I have a query like this: entityManager.createQuery("select book from Book book left join fetch book.authors").setMaxResults(10).getResultList(). I noticed that in case of join fetch setMaxResults() is ignored and the whole result set is loaded first into memory and then join fetch semantics is applied. This behaviour is perfectly understandable, because Hibernate can't know how much rows it should retrieve from the DB in order to construct 10 Book objects. But I know that a book has let's say 1.2 authors in average. Now the question: can I give Hibernate a kind of hint that it should initially retrieve 1.2*x rows from DB in order to construct x Book objects?
Thank you in advance.
Mike
|