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: Does Hibernate retrieve all the records for setMaxResults?
PostPosted: Wed Aug 05, 2009 6:55 pm 
Newbie

Joined: Wed Aug 05, 2009 6:46 pm
Posts: 1
If I use Hibernate criteria search as follows:

criteria.setFirstResult(0);
criteria.setMaxResults(5);
return criteria.list();

Suppose there are 20 records meeting the criteria, and I know the above return returns the first 5 records.

My question is:

Does Hibernate get all records from the database, removes other records internally, and then return the first 5 record

or

Does the database only returns the first five records?

Which is true?

Thanks!


Top
 Profile  
 
 Post subject: Re: Does Hibernate retrieve all the records for setMaxResults?
PostPosted: Mon Aug 10, 2009 7:15 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
It just returns the first five. You'll see this in the SQL if you configure show_sql and look at the logs.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.