-->
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.  [ 1 post ] 
Author Message
 Post subject: FetchingScrollableResultsImpl & ScrollableResultsImpl
PostPosted: Thu Jan 01, 2009 11:56 pm 
Newbie

Joined: Thu Jan 01, 2009 11:39 pm
Posts: 1
I'm using the accepted method of obtaining the number of rows from an HQL query:

Code:
query.scroll().last().getRowNumber() + 1;


and it's working ... half the time. After some investigation, I learned that there are two implementations of ScrollableResults being used: FetchingScrollableResultsImpl and ScrollableResultsImpl, and they use different bases for determining the row number.

From FetchingScrollableResultsImpl - one-based:
Code:
public boolean isFirst() throws HibernateException {
   return currentPosition == 1;
}

public int getRowNumber() throws HibernateException {
   return currentPosition;
}



From ScrollableResultsImpl - zero-based:
Code:
public int getRowNumber() throws HibernateException {
   try {
      // The underlying JDBC ResultSet is one-based.
      return getResultSet().getRow()-1;
   }
   catch (SQLException sqle) {
      ...
   }
}


Now, this looks like a bug, and smells like a bug, but I'm a cautious fellow so I thought I'd seek the counsel of those more experienced than I am for their opinion.

I'm using Hibernate 3.3.1.GA.

Cheers,

Steven.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.