Package org.hibernate

Interface ScrollableResults<R>

All Superinterfaces:
AutoCloseable
All Known Subinterfaces:
ScrollableResultsImplementor<R>
All Known Implementing Classes:
AbstractScrollableResults, EmptyScrollableResults, FetchingScrollableResultsImpl, ScrollableResultsImpl

public interface ScrollableResults<R> extends AutoCloseable
A result iterator that allows moving around within the results by arbitrary increments.
See Also:
API Note:
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.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Go to a location just after the last result.
    void
    Go to a location just before first result.
    void
    Release resources immediately.
    boolean
    Go to the first result.
    get()
    Get the current row of results.
    int
    The current position within the query results.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
     
    boolean
    Is this the first result?
    boolean
    Is this the last result?
    boolean
    Go to the last result.
    boolean
    Advance to the next result.
    boolean
    position(int position)
    Moves the result cursor to the specified position.
    boolean
    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)
    Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • get

      R get()
      Get the current row of results.
      Returns:
      The array of results
    • close

      void close()
      Release resources immediately.
      Specified by:
      close in interface AutoCloseable
    • isClosed

      boolean isClosed()
      Returns:
      true if close() was already called
    • 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 positions
      Returns:
      true if there is a result at the new location
    • position

      boolean position(int position)
      Moves the result cursor to the specified position. The index may be a positive value, and the position may be reached by counting forward from the first result at position 1, or it may be a negative value, so that the position may be reached by counting backward from the last result at position -1.
      Parameters:
      position - an absolute positive (from the start) or negative (from the end) position within the query results
      Returns:
      true if there is a result at the new location
    • getPosition

      int getPosition()
      The current position within the query results. The first query result, if any, is at position 1. An empty or newly-created instance has position 0.
      Returns:
      the current position, a positive integer index starting at 1, or 0 if this instance is empty or newly-created
      Since:
      7.0
    • 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, otherwise false
    • isLast

      boolean isLast()
      Is this the last result?
      Returns:
      true if this is the last row of results.
    • getRowNumber

      @Deprecated(since="7", forRemoval=true) int getRowNumber()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the current position in the results, with the first position labelled as row number 0. That is, this operation returns position-1.
      Returns:
      The current position number, numbered from 0; -1 indicates that there is no current row
    • setRowNumber

      @Deprecated(since="7", forRemoval=true) boolean setRowNumber(int rowNumber)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the current position in the result set, with the first position labelled as row number 1, and the last position labelled as row number -1. Results may be numbered from the first result (using a positive position) or backward from the last result (using a negative position).
      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. If 0, the JDBC driver's default setting will be used.
      Since:
      6.1.2
      See Also: