Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

number of results

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • 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
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • 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: 1281
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Mahesh Gurav
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic