-->
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: iterate shows hasNext=true when nothing returned
PostPosted: Thu Dec 04, 2003 6:03 pm 
Newbie

Joined: Thu Dec 04, 2003 6:00 pm
Posts: 5
I use session.iterate() to retrieve a list of records. I know that the first time I issue the iterate, that it should return nothing. However, it still reports hasNext as true. Here is a code snipit:

public class SegmentTypeServices {
protected static Logger logger = Logger.getLogger(SegmentTypeServices.class.getName());

public static int nextSegmentTypeCode(ControlEventContext context) throws HibernateException, AppConfigError {
Session hbSession = HibernateSession.currentSession();
Iterator maxCodeList = hbSession.iterate("select max(sgType.comp_id.sgTypeCode) from com.orci.ITSAM.hibernate.SegmentType sgType " +
"where sgType.comp_id.siteDatabase.comp_id.site = ? " +
"and sgType.comp_id.siteDatabase.comp_id.dbId = ? ",
new Object[] {
SiteDatabaseServices.MyDbSiteCode(context),
SiteDatabaseServices.MyDbId(context) },
new Type[] {
Hibernate.INTEGER,
Hibernate.INTEGER });
if (!maxCodeList.hasNext()) return 1;
Object[] row = (Object[])maxCodeList.next();
return ((Integer)row[0]).intValue();
}


When I run it I get a java.util.NoSuchElementException: No more results exception.

Any ideas?
Thanks in advance,
David Robison


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 6:13 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Yeah! Cool! I can reproduce. This must be a bug.

This happens when table is empty.

I think you need to submit this to JIRA


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 6:25 pm 
Newbie

Joined: Thu Dec 04, 2003 6:00 pm
Posts: 5
How do I do that?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 6:33 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Go to http://opensource.atlassian.com/project ... board.jspa

I think you'll figure out what to do there


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.