-->
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.  [ 3 posts ] 
Author Message
 Post subject: Pagination with key restriction to know which page to show.
PostPosted: Tue Sep 04, 2007 10:44 am 
Regular
Regular

Joined: Sat Jan 22, 2005 6:57 pm
Posts: 50
Location: Chicago
I understand how basic pagination works, and have been successful at using it in Hibernate with the setMaxResults and setFirstResult api on the criteria object.

However, now I have the a problem where the user wants to display the page of results that contains a particular key of information. For instance, if there are 10000 total rows with 10 rows per page, there are then 1000 pages of 10 rows. Based on a particular key supplied during the query, the user would want to see page 3 of data with that item selected in the results.

How can I specify this key in a criteria to ensure that the result set returns with the page of data from hibernate includes the key, and most importantly, keeps that key in its proper position within the page of data?

Thanks in advance,
Mark


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 4:34 pm 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
with criteria api you can add criterions to restrict result list.

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 5:06 pm 
Regular
Regular

Joined: Sat Jan 22, 2005 6:57 pm
Posts: 50
Location: Chicago
Yes... that is true. But I am not sure if I can get back the exact paging that I would expect. For example sake, if I have a total of 10 results and I want 2 results per page, I would expect the data to line up like this:

1
2
==== end page 1
3
4
==== end page 2
5
6
==== end page 3
7
8
==== end page 4
9
10
==== end page 5

Now, if I say that I want to show that page that contains the key "6", I would expect to get back:

5
6

Because that is how that page of data was represented, in that order. And somehow, I would like hibernate to tell me that that I was on page 3.

Is this possible?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.