-->
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.  [ 4 posts ] 
Author Message
 Post subject: Which is the preferred way of fetching results
PostPosted: Fri Oct 01, 2004 2:07 pm 
Newbie

Joined: Wed Jun 09, 2004 2:41 pm
Posts: 14
Hi,

I would like to know which is the recommended way of fetching query results.

Session s = getSession();

List list =
s.find("from User u where u.name=?", userName, Hibernate.STRING);

return list.iterator();

or

Query q = s.createQuery("from User u where u.name= :userName");
q.setString("userName", userName);
return q.iterate();


From a performance point of view is there are there any overheads between both ways?

Thanks,
Jeelani


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 01, 2004 3:01 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
there is no real concrete difference between both solutions

be carefull with .iterate().... prefer .list() if you aren't using second level cache

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 01, 2004 4:18 pm 
Newbie

Joined: Wed Jun 09, 2004 2:41 pm
Posts: 14
Thanks for the reply Anthony.

Jeelani


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 01, 2004 6:08 pm 
Newbie

Joined: Wed Jun 09, 2004 2:41 pm
Posts: 14
I could find the detailed answer for my question in Hibernate In Action, chapter -7 page 245. This follows the one said by Anthony.

Thanks,
Jeelani


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