-->
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: Iterating loaded objects
PostPosted: Sat Feb 28, 2004 10:41 pm 
Beginner
Beginner

Joined: Sun Dec 21, 2003 9:18 pm
Posts: 21
Hi,

Hibernate will load a list of objects when we call iterate() or createSQLQuery(). And so far I have found that a list's lifecycle will end when we close the session that we use to load it.

So, I if I want to display the object in the list in my JSP, I always iterate the list, and save the objects to an array list or vector. After that I will iterate this array list / vector in my JSP or Controller to display the object stored inside.

I really hate all this loop. Is there any method in hibernate that will return a persistent list. What I mean by a persistent list is that this list will not be closed or nullified when we close the session in hibernate.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2004 11:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
Hibernate will load a list of objects when we call iterate() or createSQLQuery().


No, it returns a list when you call list() or find()!


Quote:
And so far I have found that a list's lifecycle will end when we close the session that we use to load it


This is not correct.

An Iterator returned by iterate() is only valid for the length of a transaction (for obvious reasons - it wraps a ResultSet), but this does not apply to Lists.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2004 11:52 pm 
Beginner
Beginner

Joined: Sun Dec 21, 2003 9:18 pm
Posts: 21
gavin wrote:
Quote:
Hibernate will load a list of objects when we call iterate() or createSQLQuery().


No, it returns a list when you call list() or find()!


Quote:
And so far I have found that a list's lifecycle will end when we close the session that we use to load it


This is not correct.

An Iterator returned by iterate() is only valid for the length of a transaction (for obvious reasons - it wraps a ResultSet), but this does not apply to Lists.


Aplogies for my lack of understanding on the List concept. I run more test on the createSQLQuery(), and when I close the session the List is not nullified. This way i do not need to do double looping.

Thanks


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.