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. 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 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
    Get the current position in the results.
    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)
    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:
      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 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, otherwise false
    • 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. If 0, the JDBC driver's default setting will be used.
      Since:
      6.1.2
      See Also: