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.CloseableA 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 voidafterLast()Go to a location just after the last result.voidbeforeFirst()Go to a location just before first result, This is the location of the cursor on a newly returned scrollable result.voidclose()Release resources immediately.booleanfirst()Go to the first result.java.lang.Object[]get()Get the current row of results.java.lang.Objectget(int i)Get the ith object in the current row of results, without initializing any other results in the row.java.math.BigDecimalgetBigDecimal(int col)Convenience method to read a BigDecimal.java.math.BigIntegergetBigInteger(int col)Convenience method to read a BigInteger.byte[]getBinary(int col)Convenience method to read a binary (byte[]).java.sql.BlobgetBlob(int col)Convenience method to read a blob.java.lang.BooleangetBoolean(int col)Convenience method to read a boolean.java.lang.BytegetByte(int col)Convenience method to read a byte.java.util.CalendargetCalendar(int col)Convenience method to read a Calendar.java.lang.CharactergetCharacter(int col)Convenience method to read a char.java.sql.ClobgetClob(int col)Convenience method to read a clob.java.util.DategetDate(int col)Convenience method to read a Date.java.lang.DoublegetDouble(int col)Convenience method to read a double.java.lang.FloatgetFloat(int col)Convenience method to read a float.java.lang.IntegergetInteger(int col)Convenience method to read an integer.java.util.LocalegetLocale(int col)Convenience method to read a Locale.java.lang.LonggetLong(int col)Convenience method to read a long.intgetRowNumber()Get the current position in the results.java.lang.ShortgetShort(int col)Convenience method to read a short.java.lang.StringgetString(int col)Convenience method to read a string.java.lang.StringgetText(int col)Convenience method to read a String using streaming.java.util.TimeZonegetTimeZone(int col)Convenience method to read a TimeZone.TypegetType(int i)Get the type of the ith column of results.booleanisFirst()Is this the first result?booleanisLast()Is this the last result?booleanlast()Go to the last result.booleannext()Advance to the next result.booleanprevious()Retreat to the previous result.booleanscroll(int positions)Scroll the specified number of positions from the current position.booleansetRowNumber(int rowNumber)Set the current position in the result set.
-
-
-
Method Detail
-
close
void close()
Release resources immediately.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
next
boolean next()
Advance to the next result.- Returns:
trueif there is another result
-
previous
boolean previous()
Retreat to the previous result.- Returns:
trueif 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:
trueif there is a result at the new location
-
last
boolean last()
Go to the last result.- Returns:
trueif there are any results
-
first
boolean first()
Go to the first result.- Returns:
trueif 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:
trueif this is the first row of results, otherwisefalse
-
isLast
boolean isLast()
Is this the last result?- Returns:
trueif 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.
-
-