org.hibernate

Interface ScrollableResults

Known Implementing Classes:
AbstractScrollableResults, FetchingScrollableResultsImpl, ScrollableResultsImpl

public interface ScrollableResults

A result iterator that allows moving around within the results by arbitrary increments. The Query / ScrollableResults pattern is very similar to the JDBC PreparedStatement/ ResultSet pattern and the semantics of methods of this interface are similar to the similarly named methods on ResultSet.

Contrary to JDBC, columns of results are numbered from zero.
Author:
Gavin King
See Also:
Query.scroll()

Method Summary

void
afterLast()
Go to a location just after the last result
void
beforeFirst()
Go to a location just before first result (this is the initial location)
void
close()
Release resources immediately.
boolean
first()
Go to the first result
Object[]
get()
Get the current row of results
Object
get(int i)
Get the ith object in the current row of results, without initializing any other results in the row.
BigDecimal
getBigDecimal(int col)
Convenience method to read a big_decimal
BigInteger
getBigInteger(int col)
Convenience method to read a big_integer
byte[]
getBinary(int col)
Convenience method to read a binary
Blob
getBlob(int col)
Convenience method to read a blob
Boolean
getBoolean(int col)
Convenience method to read a boolean
Byte
getByte(int col)
Convenience method to read a byte
Calendar
getCalendar(int col)
Convenience method to read a calendar or calendar_date
Character
getCharacter(int col)
Convenience method to read a character
Clob
getClob(int col)
Convenience method to read a clob
Date
getDate(int col)
Convenience method to read a date, time or timestamp
Double
getDouble(int col)
Convenience method to read a double
Float
getFloat(int col)
Convenience method to read a float
Integer
getInteger(int col)
Convenience method to read an integer
Locale
getLocale(int col)
Convenience method to read a locale
Long
getLong(int col)
Convenience method to read a long
int
getRowNumber()
Get the current location in the result set.
Short
getShort(int col)
Convenience method to read a short
String
getString(int col)
Convenience method to read a string
String
getText(int col)
Convenience method to read text
TimeZone
getTimeZone(int col)
Convenience method to read a timezone
Type
getType(int i)
Get the type of the ith column of results
boolean
isFirst()
Is this the first result?
boolean
isLast()
Is this the last result?
boolean
last()
Go to the last result
boolean
next()
Advance to the next result
boolean
previous()
Retreat to the previous result
boolean
scroll(int i)
Scroll an arbitrary number of locations
boolean
setRowNumber(int rowNumber)
Set the current location in the result set, numbered from either the first row (row number 0), or the last row (row number -1).

Method Details

afterLast

public void afterLast()
            throws HibernateException
Go to a location just after the last result

beforeFirst

public void beforeFirst()
            throws HibernateException
Go to a location just before first result (this is the initial location)

close

public void close()
            throws HibernateException
Release resources immediately.

first

public boolean first()
            throws HibernateException
Go to the first result
Returns:
true if there are any results

get

public Object[] get()
            throws HibernateException
Get the current row of results
Returns:
an object or array

get

public Object get(int i)
            throws HibernateException
Get the ith object in the current row of results, without initializing any other results in the row. This method may be used safely, regardless of the type of the column (ie. even for scalar results).
Parameters:
i - the column, numbered from zero
Returns:
an object of any Hibernate type or null

getBigDecimal

public BigDecimal getBigDecimal(int col)
            throws HibernateException
Convenience method to read a big_decimal

getBigInteger

public BigInteger getBigInteger(int col)
            throws HibernateException
Convenience method to read a big_integer

getBinary

public byte[] getBinary(int col)
            throws HibernateException
Convenience method to read a binary

getBlob

public Blob getBlob(int col)
            throws HibernateException
Convenience method to read a blob

getBoolean

public Boolean getBoolean(int col)
            throws HibernateException
Convenience method to read a boolean

getByte

public Byte getByte(int col)
            throws HibernateException
Convenience method to read a byte

getCalendar

public Calendar getCalendar(int col)
            throws HibernateException
Convenience method to read a calendar or calendar_date

getCharacter

public Character getCharacter(int col)
            throws HibernateException
Convenience method to read a character

getClob

public Clob getClob(int col)
            throws HibernateException
Convenience method to read a clob

getDate

public Date getDate(int col)
            throws HibernateException
Convenience method to read a date, time or timestamp

getDouble

public Double getDouble(int col)
            throws HibernateException
Convenience method to read a double

getFloat

public Float getFloat(int col)
            throws HibernateException
Convenience method to read a float

getInteger

public Integer getInteger(int col)
            throws HibernateException
Convenience method to read an integer

getLocale

public Locale getLocale(int col)
            throws HibernateException
Convenience method to read a locale

getLong

public Long getLong(int col)
            throws HibernateException
Convenience method to read a long

getRowNumber

public int getRowNumber()
            throws HibernateException
Get the current location in the result set. The first row is number 0, contrary to JDBC.
Returns:
the row number, numbered from 0, or -1 if there is no current row

getShort

public Short getShort(int col)
            throws HibernateException
Convenience method to read a short

getString

public String getString(int col)
            throws HibernateException
Convenience method to read a string

getText

public String getText(int col)
            throws HibernateException
Convenience method to read text

getTimeZone

public TimeZone getTimeZone(int col)
            throws HibernateException
Convenience method to read a timezone

getType

public Type getType(int i)
Get the type of the ith column of results
Parameters:
i - the column, numbered from zero
Returns:
the Hibernate type

isFirst

public boolean isFirst()
            throws HibernateException
Is this the first result?
Returns:
true if this is the first row of results

isLast

public boolean isLast()
            throws HibernateException
Is this the last result?
Returns:
true if this is the last row of results

last

public boolean last()
            throws HibernateException
Go to the last result
Returns:
true if there are any results

next

public boolean next()
            throws HibernateException
Advance to the next result
Returns:
true if there is another result

previous

public boolean previous()
            throws HibernateException
Retreat to the previous result
Returns:
true if there is a previous result

scroll

public boolean scroll(int i)
            throws HibernateException
Scroll an arbitrary number of locations
Parameters:
i - a positive (forward) or negative (backward) number of rows
Returns:
true if there is a result at the new location

setRowNumber

public boolean setRowNumber(int rowNumber)
            throws HibernateException
Set the current location in the result set, numbered from either the first row (row number 0), or the last row (row number -1).
Parameters:
rowNumber - the row number, numbered from the last row, in the case of a negative row number
Returns:
true if there is a row at that row number