/** * @see org.hibernate.ScrollableResults#getBinary(int) */ public byte[] getBinary(int col) throws HibernateException { return (byte[]) getFinal(col, Hibernate.BINARY); }
/** * @see org.hibernate.ScrollableResults#getDate(int) */ public Date getDate(int col) throws HibernateException { return (Date) getNonFinal(col, Hibernate.TIMESTAMP); }
public boolean setRowNumber(int rowNumber) throws HibernateException { if (rowNumber>=0) rowNumber++; try { boolean result = getResultSet().absolute(rowNumber); prepareCurrentRow(result); return result; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( getSession().getFactory().getSQLExceptionConverter(), sqle, "could not advance using absolute()" ); } }
private void prepareCurrentRow(boolean underlyingScrollSuccessful) throws HibernateException { if (!underlyingScrollSuccessful) { currentRow = null; return; } Object result = getLoader().loadSingleRow( getResultSet(), getSession(), getQueryParameters(), false ); if ( result != null && result.getClass().isArray() ) { currentRow = (Object[]) result; } else { currentRow = new Object[] { result }; } if ( getHolderInstantiator() != null ) { currentRow = new Object[] { getHolderInstantiator().instantiate(currentRow) }; } afterScrollOperation(); }
public boolean setRowNumber(int rowNumber) throws HibernateException { if (rowNumber>=0) rowNumber++; try { boolean result = rs.absolute(rowNumber); prepareCurrentRow(result); return result; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( sess.getFactory().getSQLExceptionConverter(), sqle, "could not advance using absolute()" ); } }
public int getRowNumber() throws HibernateException { try { return getResultSet().getRow()-1; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( getSession().getFactory().getSQLExceptionConverter(), sqle, "exception calling getRow()" ); } }
/** * Check that the requested type is compatible with the * result type, and return the column value * @param col the column * @param returnType any type */ private Object getNonFinal(int col, Type returnType) throws HibernateException { if ( holderConstructor!=null ) { throw new HibernateException("query specifies a holder class"); } if ( returnType.getReturnedClass().isAssignableFrom( types[col].getReturnedClass() ) ) { return get(col); } else { return throwInvalidColumnTypeException(col, types[col], returnType); } }
return new ScrollableResultsImpl( rs, st,
/** * @see org.hibernate.ScrollableResults#last() */ public boolean last() throws HibernateException { try { boolean result = getResultSet().last(); prepareCurrentRow(result); return result; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( getSession().getFactory().getSQLExceptionConverter(), sqle, "could not advance using last()" ); } }
/** * @see org.hibernate.ScrollableResults#last() */ public boolean last() throws HibernateException { try { boolean result = rs.last(); prepareCurrentRow(result); return result; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( sess.getFactory().getSQLExceptionConverter(), sqle, "could not advance using last()" ); } }
/** * @see org.hibernate.ScrollableResults#beforeFirst() */ public void beforeFirst() throws HibernateException { try { getResultSet().beforeFirst(); } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( getSession().getFactory().getSQLExceptionConverter(), sqle, "exception calling beforeFirst()" ); } }
/** * Check that the requested type is compatible with the * result type, and return the column value * @param col the column * @param returnType a "final" type */ private Object getFinal(int col, Type returnType) throws HibernateException { if ( holderConstructor!=null ) { throw new HibernateException("query specifies a holder class"); } if ( returnType.getReturnedClass()==types[col].getReturnedClass() ) { return get(col); } else { return throwInvalidColumnTypeException(col, types[col], returnType); } }
ScrollableResults result = new ScrollableResultsImpl( rs, st, session,
/** * @see org.hibernate.ScrollableResults#next() */ public boolean next() throws HibernateException { try { boolean result = getResultSet().next(); prepareCurrentRow(result); return result; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( getSession().getFactory().getSQLExceptionConverter(), sqle, "could not advance using next()" ); } }
/** * @see org.hibernate.ScrollableResults#next() */ public boolean next() throws HibernateException { try { boolean result = rs.next(); prepareCurrentRow(result); return result; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( sess.getFactory().getSQLExceptionConverter(), sqle, "could not advance using next()" ); } }
/** * @see org.hibernate.ScrollableResults#afterLast() */ public void afterLast() throws HibernateException { try { getResultSet().afterLast(); } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( getSession().getFactory().getSQLExceptionConverter(), sqle, "exception calling afterLast()" ); } }
/** * @see org.hibernate.ScrollableResults#getLocale(int) */ public Locale getLocale(int col) throws HibernateException { return (Locale) getFinal(col, Hibernate.LOCALE); }
/** * @see org.hibernate.ScrollableResults#getBlob(int) */ public Blob getBlob(int col) throws HibernateException { return (Blob) getNonFinal(col, Hibernate.BLOB); }
/** * @see org.hibernate.ScrollableResults#scroll(int) */ public boolean scroll(int i) throws HibernateException { try { boolean result = getResultSet().relative(i); prepareCurrentRow(result); return result; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( getSession().getFactory().getSQLExceptionConverter(), sqle, "could not advance using scroll()" ); } }
/** * @see org.hibernate.ScrollableResults#scroll(int) */ public boolean scroll(int i) throws HibernateException { try { boolean result = rs.relative(i); prepareCurrentRow(result); return result; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( sess.getFactory().getSQLExceptionConverter(), sqle, "could not advance using scroll()" ); } }