• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

number of results

 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the app i'm building user has a form where can make inserts and can either edit or delete them.
I wonder if later on, when one has thousands of records, i have to load the entire table (with those thousand records).
I know hibernate has a way of just loading say - last 10, 50 records.
But that would imply i'd have to build a user interface more complex: with navigation (first, last, next, previous) and also another group of buttons with: next 50, previous 50 and so on...
How do experts usually solve this kind of problem?
thanks in advance
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I leave this up to the business users -- with help from developers of course -- to choose how they want to use it. Sometimes I'll provide search fields or dropdown select lists. Other times they want to page through results. It really depends on how the application will be used.

For example, a list of parts in a catalog would benefit from searching or drill-down tables of contents (think of the JavaDocs) rather than paging through 100,000 products in alphabetical order.

If you'd like, describe a specific case and we can give you more concrete examples.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Other times they want to page through results


imagine my user will insert thousands of records; if she wants a certain one, i can provide a search capability; but what if she just wants to page through?
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found these through Google. First, from the Hibernate User FAQ:

I want to retrieve query results, one page at a time

Use Query.setMaxResults() and Query.setFirstResult() for query paging.

Second, this page talks about an interface that someone wrote to help with this. It mentions new support in 2.1.8, but not what it is.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David & miguel ,
I am also facing same problem i tried using setFirstResult() & setMaxResult as well.But my requirement is slightely different.
If 100 records are fetched,25 records per page i want to show it like
<prev 1 2 3 4 next> ,i can not determine how many page numbers i sholuld show if i used above mentioned two methods as they limit result size itself.
What should i do to get size of result according to which i will show pageNumbers & on click of each number i will fetch & show query result of that page by using setFirstResult() & setMaxResults().
i am using struts-hibernate3,& criteria in hibernate.
Any Help!!! :roll:
MAHESH
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mahesh,

I think you will have to fire one more query something like "select count (*) ..... " to find number of records.


-P
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic