/** * Retreat to the previous result * * @return <tt>true</tt> if there is a previous result */ public boolean previous() throws HibernateException { if ( currentPosition <= 1 ) { currentPosition = 0; currentRow = null; return false; } Object loadResult = getLoader().loadSequentialRowsReverse( getResultSet(), getSession(), getQueryParameters(), false, ( maxPosition != null && currentPosition > maxPosition.intValue() ) ); currentRow = new Object[] { loadResult }; currentPosition--; afterScrollOperation(); return true; }
/** * Go to the first result * * @return <tt>true</tt> if there are any results */ public boolean first() throws HibernateException { beforeFirst(); boolean more = next(); afterScrollOperation(); return more; }
/** * Set the current location in the result set, numbered from either the first row (row number <tt>0</tt>), or the last * row (row number <tt>-1</tt>). * * @param rowNumber the row number, numbered from the last row, in the case of a negative row number * * @return true if there is a row at that row number */ public boolean setRowNumber(int rowNumber) throws HibernateException { if ( rowNumber == 1 ) { return first(); } else if ( rowNumber == -1 ) { return last(); } else if ( maxPosition != null && rowNumber == maxPosition.intValue() ) { return last(); } return scroll( rowNumber - currentPosition ); } }
/** * Go to a location just after the last result */ public void afterLast() throws HibernateException { // TODO : not sure the best way to handle this. // The non-performant way : last(); next(); afterScrollOperation(); }
if ( maxPosition != null ) { for ( int i = currentPosition; i < maxPosition.intValue(); i++ ) { more = next(); if ( getResultSet().isAfterLast() ) { while ( !getResultSet().isAfterLast() ) { more = next(); getSession().getFactory().getSQLExceptionConverter(), e, "exception calling isAfterLast()" afterScrollOperation();
more = next(); if ( !more ) { break; more = previous(); if ( !more ) { break; afterScrollOperation();
/** * Go to a location just before first result (this is the initial location) */ public void beforeFirst() throws HibernateException { try { getResultSet().beforeFirst(); } catch( SQLException e ) { throw JDBCExceptionHelper.convert( getSession().getFactory().getSQLExceptionConverter(), e, "exception calling beforeFirst()" ); } currentRow = null; currentPosition = 0; }
return new FetchingScrollableResultsImpl( rs, st,
Object row = getLoader().loadSequentialRowsForward( getResultSet(), getSession(), getQueryParameters(), false ); afterLast = getResultSet().isAfterLast(); getSession().getFactory().getSQLExceptionConverter(), e, "exception calling isAfterLast()" afterScrollOperation();