-->
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: Criteria.setFirstResult Problem
PostPosted: Fri Oct 05, 2007 10:12 am 
Newbie

Joined: Fri Oct 05, 2007 10:04 am
Posts: 1
I have a strange behaviour with the Criteria.setFirstResult method.

In my db there is a table items containing 100 items with id's from 1 to 100

When I query the items with

criteria.setFirstResult(1);
criteria.setMaxResults(20);

It returns the items 21 to 40.

But when I do this:
criteria.setFirstResult(0);
criteria.setMaxResults(20);

Only the first 10 items are returned. It seems that when FirstResult=0, always the first 10 items are returned.

Can someone explain this behaviour to me?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 06, 2007 8:02 pm 
Regular
Regular

Joined: Sun Sep 30, 2007 7:51 pm
Posts: 93
It should work...

setFirstResulst counts from zero. So to itterate over 100 entriies, it should be something like:

//first 20 results
setFirstResult(0)
setMaxResults(20)

//second 20 resutls
setFirstResult(20)
setMaxresults(20)

etc...

Regards,
Pavol


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.