-->
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: Lazy queries, as opposed to lazy collections
PostPosted: Tue Nov 09, 2004 10:01 am 
Beginner
Beginner

Joined: Tue Nov 09, 2004 9:48 am
Posts: 23
Gentlemen,

I am fairly new to Hibernate and have a question about lazy fetching. The lazy fetching of collections is very nice, but is it possible to fetch lazily on the topmost query level? In other words, if I have a Person class that contains 100,000 objects, and I do a "from Person" query, is there a way to tell hibernate to only fetch the first 1000 rows into a HashMap, and then fetch subsequent data if needed based on the index being accessed?

So, if I've fetched the initial 1000 rows into "map", and in the code I do a "map.get(1050)", this would cause Hibernate to fetch the next 1000 rows to fulfill the fetch requirements. If I did a "map.get(50010)", this would cause Hibernate to fetch records 50000-51000.

Thank you very much for your time.

Jbwiv


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 09, 2004 10:04 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Write a small wrapper method around setFirstResult/setNextResult of the Query API.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.