-->
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: I cant iterate over a sql resultset???
PostPosted: Sun Mar 11, 2007 12:09 am 
Newbie

Joined: Thu Mar 08, 2007 1:58 pm
Posts: 6
If I have a Query using SQL surely I can do the basic steps of

while (resultSet.next()) {
// do something with one row
}

But there appears to be now such method on the Query object. Trying to use the Iterator fails.

This is quite surprising, along the lines of losing access to the meta data which the basic JDBC implementation provides from the java.sql packages.

Do I have to write two sets of code - one for JDBC for dynamic SQL and reports and 'efficient' coding, the other using Hibernate for object access?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 11, 2007 6:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
To me, what your showing is pure JDBC approach. Which is fine but your not using hibernates APIs. HIbernate provides a collection as the results set so you interate over it using java.util.Iterator (or jdk5 for loop). There might be cases where you need to go to the JDBC level to accomplish something (which will not be often at all). Report queries can be performed efficiently using Hibernate but you may have cases where you decided to employ JDBC level code. I do not see this as being necessarily bad.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 14, 2007 10:54 pm 
Newbie

Joined: Thu Mar 08, 2007 1:58 pm
Posts: 6
I would be happy if the Hibernate iterator worked for SQL queries, so I can iterate over the array of objects returned.

But it doesnt so I can do nothing but return the entire resultset which forces me to change my architecture if I want to continue to not use JDBC.


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.