-->
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.  [ 5 posts ] 
Author Message
 Post subject: ScrollableResults and large result set
PostPosted: Thu Apr 15, 2004 4:42 am 
Newbie

Joined: Thu Apr 15, 2004 3:55 am
Posts: 3
Hi,

I am using Hibernate 2.1 and Oralce 9. I am using a query that may return a very large result set. I dont want to use list() because this would eat up my memory. I also dont want to use iterate(), beacuse this would do a select for every single object that i use and I am actually reading all of them. So I tried to use ScrollableResults. Here is my code:

...
Query q = hbnSession.createQuery("SELECT flight FROM PreSkedFlight flight JOIN flight.opLegs as leg WHERE leg.departureAirport = :airport OR leg.arrivalAirport = :airport ");
q.setString("airport", airport);
result = q.scroll();
...
if (result.first()) {
do {
curFlight = (PreSkedFlight)result.get(0);
...
} while (result.next());
}
...

I would suppose, that this does what i intended. But looking at my DB logs it seems like the query for the ScrollableResults only gets the object keys. Then for every result.get() a new select is called to fetch the object.

Is there a way to avoid this problem or how to deal with large result sets?
Thanks,
Conrad


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 15, 2004 5:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
you are supposed to use setMaxResults() for this.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 15, 2004 5:46 am 
Newbie

Joined: Thu Apr 15, 2004 3:55 am
Posts: 3
gavin wrote:
you are supposed to use setMaxResults() for this.


In this case I have to give up Oracles statement level read consistency feature. Using setMaxResults() and setFirstResult() would do a new select and I might have dirty-reads ... I guess that I have to live with that anyway.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 15, 2004 8:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
If you are in one transaction, you can set the appropriate isolation level to have repeatable read even with multiple selects.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 15, 2004 8:31 am 
Newbie

Joined: Thu Apr 15, 2004 3:55 am
Posts: 3
michael wrote:
If you are in one transaction, you can set the appropriate isolation level to have repeatable read even with multiple selects.

Yes, I know. But I think oracle might handle concurrency better if its just one select. I was reflecting if there is a way of doing that, but thank you for your feedback.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.