-->
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.  [ 3 posts ] 
Author Message
 Post subject: Another large collection question - maybe simple
PostPosted: Fri Jul 22, 2005 10:27 am 
Newbie

Joined: Thu Mar 24, 2005 11:15 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

Mapping documents: none yet

Code between sessionFactory.openSession() and session.close(): none

Full stack trace of any exception that occurs: n/a

Name and version of the database you are using: many

The generated SQL (show_sql=true): none

Debug level Hibernate log excerpt: none

I see many threads about retrieving large collections, but none seem applicable to my needs. I need to be able to iterate through a very large set of objects and operate on them. Performance is not a huge driver in this issue. All my reading about lazy loading seems to reference associations (like the wiki or Hibernate In Action), but the associations are not relevant in this case - I just don't want to load 200,000 objects at once.

I need to either:
(1) lazy-load the objects themselves, but lazy loading doesn't seem to apply here or
(2) do something more complex like generically retrieve just the ids and then iterate through the id object collection and load the objects one at a time, but I don't see how to do that at runtime. I was hoping metadata would help, but I didn't see how.

Any suggestions? This has to be very generic. I can't specify something in the mappings or hard-code any SQL or HQL. Any suggestions?


Top
 Profile  
 
 Post subject: Re: Another large collection question - maybe simple
PostPosted: Fri Jul 22, 2005 10:40 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
angry planet wrote:
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

Mapping documents: none yet

Code between sessionFactory.openSession() and session.close(): none

Full stack trace of any exception that occurs: n/a

Name and version of the database you are using: many

The generated SQL (show_sql=true): none

Debug level Hibernate log excerpt: none

I see many threads about retrieving large collections, but none seem applicable to my needs. I need to be able to iterate through a very large set of objects and operate on them. Performance is not a huge driver in this issue. All my reading about lazy loading seems to reference associations (like the wiki or Hibernate In Action), but the associations are not relevant in this case - I just don't want to load 200,000 objects at once.

I need to either:
(1) lazy-load the objects themselves, but lazy loading doesn't seem to apply here or
(2) do something more complex like generically retrieve just the ids and then iterate through the id object collection and load the objects one at a time, but I don't see how to do that at runtime. I was hoping metadata would help, but I didn't see how.

Any suggestions? This has to be very generic. I can't specify something in the mappings or hard-code any SQL or HQL. Any suggestions?


This sounds similar to what you might want to do in a webapp if you were only showing 1 page of results at a time.

The reference docs give examples for doing pagination and if your JDBC driver supports scrollable ResultSets, you can use query.scroll() to retrieve the data in a more usable manner.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 10:53 am 
Newbie

Joined: Thu Mar 24, 2005 11:15 am
Posts: 8
That is a great point, and one I forgot to address in my original question. I was looking at using setFirstResult and setMaxResults, but I am terrified that the order from the database is not guaranteed, and that iterating though the list this way might leave some objects un-retrieved and other doubly-retrieved. Is this a possibility?


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