-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: query.setMaxResults() and join fetch
PostPosted: Tue Nov 14, 2006 6:07 am 
Newbie

Joined: Wed Nov 05, 2003 6:47 am
Posts: 14
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 9:51 am 
Regular
Regular

Joined: Tue Feb 24, 2004 11:42 am
Posts: 56
post mapping file for books and authors if you can


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.