-->
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.  [ 1 post ] 
Author Message
 Post subject: Exact Date-based Paging
PostPosted: Thu Aug 24, 2006 11:38 pm 
Newbie

Joined: Thu Aug 24, 2006 11:03 pm
Posts: 1
Because of the type of application, I can't use the standard "next 10 items" type of paging. In many applications, you can start at offset 10 for the second page. My situation is a bit different. I'm using Hibernate3 and various databases (Oracle9, MySQL 4.1, MS SQL server).

First, I need to page based on a time interval (say 1 day). I can accomplish this using "between" with the date range. Second, I need to know when there is older and newer data, to show the "next" and "previous" links. Currently I'm doing this by doing a second select for the "MIN(paging_field), MAX(paging_field)". Third, in most situations I want a "sliding window", so that page 2 will contain 24 hours worth of items, regardless of where the next item lies relative to the end of the first page. This prevents seeing a blank page with previous and next links. When the sliding window is used, I do a third query for the "MIN(paging_field) where paging_field > window_start".

This all works great for me. It doesn't fetch the entire result set, since there are instances with large result sets. It works flawlessly in the face of changing data. The paging_field has a key on it. It's all pretty fast with the number of hits we have (kind of a pain to code though). My question is this: without using stored procedures (I don't have access to add them to this database), is there a better way to accomplish this with fewer than 3 queries? (1: global min/max 2: local min 3: fetch data), or should I stick with this strategy? Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.