Package org.hibernate
Interface ScrollableResults
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Subinterfaces:
ScrollableResultsImplementor
public interface ScrollableResults extends java.lang.AutoCloseable, java.io.Closeable
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.- See Also:
Query.scroll()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
afterLast()
Go to a location just after the last result.void
beforeFirst()
Go to a location just before first result, This is the location of the cursor on a newly returned scrollable result.void
close()
Release resources immediately.boolean
first()
Go to the first result.java.lang.Object[]
get()
Get the current row of results.java.lang.Object
get(int i)
Get the ith object in the current row of results, without initializing any other results in the row.java.math.BigDecimal
getBigDecimal(int col)
Convenience method to read a BigDecimal.java.math.BigInteger
getBigInteger(int col)
Convenience method to read a BigInteger.byte[]
getBinary(int col)
Convenience method to read a binary (byte[]).java.sql.Blob
getBlob(int col)
Convenience method to read a blob.java.lang.Boolean
getBoolean(int col)
Convenience method to read a boolean.java.lang.Byte
getByte(int col)
Convenience method to read a byte.java.util.Calendar
getCalendar(int col)
Convenience method to read a Calendar.java.lang.Character
getCharacter(int col)
Convenience method to read a char.java.sql.Clob
getClob(int col)
Convenience method to read a clob.java.util.Date
getDate(int col)
Convenience method to read a Date.java.lang.Double
getDouble(int col)
Convenience method to read a double.java.lang.Float
getFloat(int col)
Convenience method to read a float.java.lang.Integer
getInteger(int col)
Convenience method to read an integer.java.util.Locale
getLocale(int col)
Convenience method to read a Locale.java.lang.Long
getLong(int col)
Convenience method to read a long.int
getRowNumber()
Get the current position in the results.java.lang.Short
getShort(int col)
Convenience method to read a short.java.lang.String
getString(int col)
Convenience method to read a string.java.lang.String
getText(int col)
Convenience method to read a String using streaming.java.util.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 positions)
Scroll the specified number of positions from the current position.boolean
setRowNumber(int rowNumber)
Set the current position in the result set.
-
-
-
Method Detail
-
close
void close()
Release resources immediately.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
next
boolean next()
Advance to the next result.- Returns:
true
if there is another result
-
previous
boolean previous()
Retreat to the previous result.- Returns:
true
if there is a previous result
-
scroll
boolean scroll(int positions)
Scroll the specified number of positions from the current position.- Parameters:
positions
- a positive (forward) or negative (backward) number of rows- Returns:
true
if there is a result at the new location
-
last
boolean last()
Go to the last result.- Returns:
true
if there are any results
-
first
boolean first()
Go to the first result.- Returns:
true
if there are any results
-
beforeFirst
void beforeFirst()
Go to a location just before first result, This is the location of the cursor on a newly returned scrollable result.
-
afterLast
void afterLast()
Go to a location just after the last result.
-
isFirst
boolean isFirst()
Is this the first result?- Returns:
true
if this is the first row of results, otherwisefalse
-
isLast
boolean isLast()
Is this the last result?- Returns:
true
if this is the last row of results.
-
getRowNumber
int getRowNumber()
Get the current position in the results. The first position is number 0 (unlike JDBC).- Returns:
- The current position number, numbered from 0; -1 indicates that there is no current row
-
setRowNumber
boolean setRowNumber(int rowNumber)
Set the current position in the result set. Can be numbered from the first position (positive number) or the last row (negative number).- Parameters:
rowNumber
- the row number. A positive number indicates a value numbered from the first row; a negative number indicates a value numbered from the last row.- Returns:
- true if there is a row at that row number
-
get
java.lang.Object[] get()
Get the current row of results.- Returns:
- The array of results
-
get
java.lang.Object get(int i)
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:
- The requested result object; may return
null
- Throws:
java.lang.IndexOutOfBoundsException
- If i is an invalid index.
-
getType
Type getType(int i)
Get the type of the ith column of results.- Parameters:
i
- the column, numbered from zero- Returns:
- the Hibernate type
- Throws:
java.lang.IndexOutOfBoundsException
- If i is an invalid index.
-
getInteger
java.lang.Integer getInteger(int col)
Convenience method to read an integer.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as an integer
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getLong
java.lang.Long getLong(int col)
Convenience method to read a long.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a long
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getFloat
java.lang.Float getFloat(int col)
Convenience method to read a float.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a float
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getBoolean
java.lang.Boolean getBoolean(int col)
Convenience method to read a boolean.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a boolean
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getDouble
java.lang.Double getDouble(int col)
Convenience method to read a double.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a double
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getShort
java.lang.Short getShort(int col)
Convenience method to read a short.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a short
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getByte
java.lang.Byte getByte(int col)
Convenience method to read a byte.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a byte
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getCharacter
java.lang.Character getCharacter(int col)
Convenience method to read a char.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a char
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getBinary
byte[] getBinary(int col)
Convenience method to read a binary (byte[]).- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a binary (byte[])
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getText
java.lang.String getText(int col)
Convenience method to read a String using streaming.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a String
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getBlob
java.sql.Blob getBlob(int col)
Convenience method to read a blob.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a Blob
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getClob
java.sql.Clob getClob(int col)
Convenience method to read a clob.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a Clob
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getString
java.lang.String getString(int col)
Convenience method to read a string.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a String
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getBigDecimal
java.math.BigDecimal getBigDecimal(int col)
Convenience method to read a BigDecimal.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a BigDecimal
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getBigInteger
java.math.BigInteger getBigInteger(int col)
Convenience method to read a BigInteger.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a BigInteger
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getDate
java.util.Date getDate(int col)
Convenience method to read a Date.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a Date
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getLocale
java.util.Locale getLocale(int col)
Convenience method to read a Locale.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a Locale
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getCalendar
java.util.Calendar getCalendar(int col)
Convenience method to read a Calendar.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a Calendar
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
getTimeZone
java.util.TimeZone getTimeZone(int col)
Convenience method to read a TimeZone.- Parameters:
col
- The column, numbered from zero- Returns:
- The column value as a TimeZone
- Throws:
java.lang.IndexOutOfBoundsException
- If col is an invalid index.
-
-