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: 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 4:15 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Yes, the display tag is horrible because it stores everything in memory, not just the page being displayed.

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

Hibernate queries only provide methods for setting the initial row and the number of items They do not scroll in "pages". So all those calculations would have to be done through extra Java code, and passed on to your JSP as beans or variables.


Quote:
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

Again, through custom Java code. Annoyingly, Hibernate queries with pagination, don't even provide you with the total count! (i.e., the count(*) of items if they were not paginated).

I usually execute 2 queries for each of these requests: one, the paginated query itsel,f the other, a query with the same parameters but calculating the count(*).
Your page size should be a configuration parameter. And you would hold a session-wide pointer which would hold the page on which you are sitting at any given point. It gets messy.

_________________
Gonzalo Díaz


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.