Package org.hibernate
Interface ScrollableResults<R>
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
ScrollableResultsImplementor<R>
- All Known Implementing Classes:
AbstractScrollableResults,EmptyScrollableResults,FetchingScrollableResultsImpl,ScrollableResultsImpl
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 so the semantics of methods
of this interface are similar to the similarly-named methods of
ResultSet.
Contrary to JDBC, columns of results are numbered from zero.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidGo to a location just after the last result.voidGo to a location just before first result.voidclose()Release resources immediately.booleanfirst()Go to the first result.get()Get the current row of results.intGet the current position in the 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.booleanposition(int position) Moves the result cursor to the specified position.booleanprevious()Retreat to the previous result.booleanscroll(int positions) Scroll the specified number of positions from the current position.voidsetFetchSize(int fetchSize) Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed.booleansetRowNumber(int rowNumber) Set the current position in the result set.
-
Method Details
-
get
R get()Get the current row of results.- Returns:
- The array of results
-
close
void close()Release resources immediately.- Specified by:
closein interfaceAutoCloseable
-
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
-
position
boolean position(int position) Moves the result cursor to the specified position.- 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 result (positive number) or backward from the last result (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
-
setFetchSize
void setFetchSize(int fetchSize) Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. If0, the JDBC driver's default setting will be used.- Since:
- 6.1.2
- See Also:
-