Package org.hibernate
Interface ScrollableResults<R>
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Subinterfaces:
ScrollableResultsImplementor<R>
- All Known Implementing Classes:
AbstractScrollableResults
,EmptyScrollableResults
,FetchingScrollableResultsImpl
,ScrollableResultsImpl
public interface ScrollableResults<R> extends AutoCloseable, Closeable
A result iterator that allows moving around within the results by arbitrary increments. TheQuery
/ScrollableResults
pattern is very similar to the JDBCPreparedStatement
/ResultSet
pattern and so the semantics of methods of this interface are similar to the similarly-named methods ofResultSet
.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.void
close()
Release resources immediately.boolean
first()
Go to the first result.R
get()
Get the current row of results.int
getRowNumber()
Get the current position in the 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
position(int position)
Moves the result cursor to the specified position.boolean
previous()
Retreat to the previous result.boolean
scroll(int positions)
Scroll the specified number of positions from the current position.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.boolean
setRowNumber(int rowNumber)
Set the current position in the result set.
-
-
-
Method Detail
-
get
R get()
Get the current row of results.- Returns:
- The array of results
-
close
void close()
Release resources immediately.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
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
-
position
boolean position(int position)
Moves the result cursor to the specified position.- 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 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:
ResultSet.setFetchSize(int)
,AvailableSettings.STATEMENT_FETCH_SIZE
-
-