-->
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.  [ 4 posts ] 
Author Message
 Post subject: hibernate paging
PostPosted: Thu Nov 13, 2008 2:23 pm 
Newbie

Joined: Thu Nov 13, 2008 2:08 pm
Posts: 3
hello guys

I need db level [hibernate] paging on my application

like

<< first < previous [1 2 3 4 5 6 7 8 .......] next > Last >>

---------or paging like in this forum 1 2 3 ... 317 318 319 next-----------

i used display tag and value list but the problem is that resulting query data is just infinite and i need to have db level paging [server memory issue]

please guide me if there is any hibernate plug in that automatically does this
or any other way of archiving this in a spring hibernate [web] application

I search about this on internet and find some good examples but being not so intelligent i need to know

1) how << first < previous [1 2 3 4 5 6 7 8 .......] next > Last >> should be calculated for jsp page

2) and how clicking on a particular link from << first < previous [1 2 3 4 5 6 7 8 .......] next > Last >> gets the result for that particular number

please help me

..................................
kind regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 13, 2008 2:34 pm 
Newbie

Joined: Wed Aug 22, 2007 5:09 pm
Posts: 5
All you need to do is set a MaxResultCount, and keep track of the index.

So if each page is 50 results, you'll send in an index of 0, and a maxresultset of 50.

Like so.

ICriteria crit = NHibernateSession...

crit.SetFirstResult(index);
crit.SetMaxResults(50);

return crit.List();

then your next index will be "50", "100", "150", etc...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2008 1:45 am 
Newbie

Joined: Thu Nov 13, 2008 2:08 pm
Posts: 3
thank you mbraunwart for your reply actually my problem is that i also need to display the user that how many record(s) are there in database and


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2008 3:42 pm 
Newbie

Joined: Wed Aug 22, 2007 5:09 pm
Posts: 5
You can set a projection (aggregate) and perform a row count, its minimal hit with usually subsecond results. return a unique result with a count.


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