-->
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: Need your expertise to avoid firing queries every time
PostPosted: Tue Apr 25, 2006 2:58 am 
Newbie

Joined: Tue Apr 25, 2006 2:33 am
Posts: 1
Location: Chennai, India
Hi,

I am working on a project where I am making use of Hibernate for the first time. I am also using
Quote:
displayTag
for pagination, sorting etc.

When I am suppose to display 1000+ records [say 20 record/page], the pages are loading very slowly.
Also, I find the querry getting fired every time I move on to the next page.
My idea of effective fetching and displaying 1000s of records is fire the querry once and iterate
through the list for every page without hitting the database. Is this idea practicaly feasible ? If yes, can you give me hints how to implement the same. In short I do not want to hit the database again and again

or

Is it possible to fetch only first 20 records for the first page and then fetch next 20 records for next page and so on.
Kindly share your expertise.

Thanks in advance.

Details:

Hibernate version: 3.0

Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true):
select MIN(sbbid0_.PER_HOUR_RATE) as col_0_0_, sbbid0_.REQ_LINE_ITEM_ID as col_1_0_, sbbid0_.REQUIREMENT_ID as col_2_0_ from BID sbbid0_, REQ_LINE_ITEM sbreqlinei1_ where (sbbid0_.BID_STATUS_CODE in (10 , 40 , 50 , 60 , 61 , 70 , 80 , 90 , 95 , 33 , 43)) and (sbbid0_.BID_STATUS_CODE not in (33 , 43)) and sbbid0_.DELETION_MARK=0 and sbbid0_.FIT_PERCENTAGE>=sbreqlinei1_.THRESHOLD_OF_FIT and sbreqlinei1_.DELETION_MARK<>1 and sbbid0_.COST_OF_SKILLS>=(select min(sbbid2_.COST_OF_SKILLS) from BID sbbid2_ where sbbid2_.REQ_LINE_ITEM_ID=sbreqlinei1_.REQ_LINE_ITEM_ID and sbbid2_.REQUIREMENT_ID=sbreqlinei1_.REQUIREMENT_ID and (sbbid2_.BID_STATUS_CODE in (10 , 40 , 50 , 60 , 61 , 70 , 80 , 90 , 95 , 33 , 43)) and (sbbid2_.BID_STATUS_CODE not in (33 , 43)) and sbbid2_.DELETION_MARK<>1 and sbbid0_.REQ_LINE_ITEM_ID=sbbid2_.REQ_LINE_ITEM_ID and sbbid0_.REQUIREMENT_ID=sbbid2_.REQUIREMENT_ID and sbbid0_.BID_ID=sbbid2_.BID_ID) group by sbbid0_.REQ_LINE_ITEM_ID , sbbid0_.REQUIREMENT_ID

Quote:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 10:26 am 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
take a look at Criteria.setFirstResult() and Criteria.setMaxResults()
similar methods exist for Query also.


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.