Class Query

All Implemented Interfaces:
Closeable, AutoCloseable, Configurable<Query>, ResultBearing

public class Query extends SqlStatement<Query> implements ResultBearing
Statement providing convenience result handling for SQL queries.
  • Constructor Details

  • Method Details

    • execute

      public <R> R execute(ResultProducer<R> producer)
      Executes the query, returning the result obtained from the given ResultProducer.
      Type Parameters:
      R - the type of the result
      producer - the result producer.
      value returned by the result producer.
    • scanResultSet

      public <R> R scanResultSet(ResultSetScanner<R> resultSetScanner)
      Description copied from interface: ResultBearing
      Invokes the mapper with a result set supplier, and returns the value returned by the mapper.
      Specified by:
      scanResultSet in interface ResultBearing
      Type Parameters:
      R - result type returned by the mapper.
      resultSetScanner - result set scanner
      the value returned by the mapper.
    • setFetchSize

      public Query setFetchSize(int fetchSize)
      Specify the fetch size for the query. This should cause the results to be fetched from the underlying RDBMS in groups of rows equal to the number passed. This is useful for doing chunked streaming of results when exhausting memory could be a problem.
      fetchSize - the number of rows to fetch in a bunch
      the modified query
    • setMaxRows

      public Query setMaxRows(int maxRows)
      Specify the maximum number of rows the query is to return. This uses the underlying JDBC Statement.setMaxRows(int)}.
      maxRows - maximum number of rows to return
      modified query
    • setMaxFieldSize

      public Query setMaxFieldSize(int maxFields)
      Specify the maximum field size in the result set. This uses the underlying JDBC Statement.setMaxFieldSize(int)
      maxFields - maximum field size
      modified query
    • concurrentUpdatable

      public Query concurrentUpdatable()
      Specify that the result set should be concurrent updatable. This will allow the update methods to be called on the result set produced by this Query.
      the modified query
    • getHandle

      public final Handle getHandle()
    • getConfig

      public ConfigRegistry getConfig()
      Description copied from interface: Configurable
      Returns the configuration registry associated with this object.
      Specified by:
      getConfig in interface Configurable<This>
      the configuration registry associated with this object.
    • getContext

      public final StatementContext getContext()
      Returns the statement context associated with this statement.
      the statement context associated with this statement.
    • attachToHandleForCleanup

      @Beta public final Query attachToHandleForCleanup()
      Registers with the handle for cleaning when the handle is closed.
      There are some situations where Statements need to be cleaned up to avoid resource leaks. This method registers the current Statement it with the Handle. If the statement or the context are cleaned by themselves, it will automatically unregister, so in normal operations, resources should not pool for cleanup with the Handle.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • equals

      public final boolean equals(Object o)
      equals in class Object
    • hashCode

      public final int hashCode()
      hashCode in class Object