Interface ResultReader<RS,IDX>

Type Parameters:
RS - The result set
IDX - The index type
All Known Implementing Classes:
AbstractDelegatingResultReader, ColumnIndexCallableResultReader, ColumnIndexR2dbcResultReader, ColumnIndexResultSetReader, ColumnNameByIndexCallableResultReader, ColumnNameByIndexR2dbcResultReader, ColumnNameCallableResultReader, ColumnNameExistenceAwareCallableResultReader, ColumnNameExistenceAwareR2dbcResultSetReader, ColumnNameExistenceAwareReadableR2dbcResultReader, ColumnNameExistenceAwareResultSetReader, ColumnNameR2dbcResultReader, ColumnNameResultSetReader

public interface ResultReader<RS,IDX>
A result reader is a type that is capable of reading data from the given result set type.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Object
    The object the resolved column ordinals belong to, compared by identity by callers that cache them.
    default <T> T
    convertRequired(Object value, io.micronaut.core.type.Argument<T> type)
    Convert the value to the given type.
    default <T> T
    convertRequired(Object value, Class<T> type)
    Convert the value to the given type.
    default int
    findColumnIndex(RS resultSet, String columnName)
    Resolves the ordinal of the column with the given name in the result set, so that callers can cache it and read the values of subsequent rows by index using getColumnIndexReader() instead of resolving the column name for every row.
    default @Nullable ResultReader<RS,Integer>
    The reader capable of reading values by the ordinals resolved by findColumnIndex(Object, String).
    default io.micronaut.core.convert.ConversionService
    Get conversion service.
    <T> @Nullable T
    getRequiredValue(RS resultSet, IDX name, Class<T> type)
    Get a value from the given result set for the given name and type.
    default <T> T
    getRequiredValueNonNull(RS resultSet, IDX name, Class<T> type)
    Get a value from the given result set for the given name and type.
    boolean
    next(RS resultSet)
    Move the index to the next result if possible.
    default @Nullable BigDecimal
    readBigDecimal(RS resultSet, IDX name)
    Read a BigDecimal value for the given name.
    default boolean
    readBoolean(RS resultSet, IDX name)
    Read a boolean value for the given name.
    default byte
    readByte(RS resultSet, IDX name)
    Read a byte value for the given name.
    default byte @Nullable []
    readBytes(RS resultSet, IDX name)
    Read a byte[] value for the given name.
    default char
    readChar(RS resultSet, IDX name)
    Read a char value for the given name.
    default @Nullable Date
    readDate(RS resultSet, IDX name)
    Read a date value for the given name.
    default double
    readDouble(RS resultSet, IDX name)
    Read a double value for the given name.
    default @Nullable Duration
    readDuration(RS resultSet, IDX name)
    Read a duration value for the given name.
    default @Nullable Object
    readDynamic(RS resultSet, IDX index, DataType dataType)
    Read a value dynamically using the result set and the given name and data type.
    default float
    readFloat(RS resultSet, IDX name)
    Read a float value for the given name.
    default int
    readInt(RS resultSet, IDX name)
    Read an int value for the given name.
    default long
    readLong(RS resultSet, IDX name)
    Read a long value for the given name.
    default @Nullable Period
    readPeriod(RS resultSet, IDX name)
    Read a period value for the given name.
    default short
    readShort(RS resultSet, IDX name)
    Read a short value for the given name.
    default @Nullable String
    readString(RS resultSet, IDX name)
    Read a string value for the given name.
    default @Nullable Time
    readTime(RS resultSet, IDX index)
    Read a time value for the given index.
    default @Nullable Date
    readTimestamp(RS resultSet, IDX index)
    Read a timestamp value for the given index.
    default @Nullable UUID
    readUUID(RS resultSet, IDX name)
    Read a UUID value for the given name.
  • Method Details

    • convertRequired

      default <T> T convertRequired(Object value, Class<T> type)
      Convert the value to the given type.
      Type Parameters:
      T - The generic type
      Parameters:
      value - The value
      type - The type
      Returns:
      The converted value
      Throws:
      DataAccessException - if the value cannot be converted
    • convertRequired

      default <T> T convertRequired(Object value, io.micronaut.core.type.Argument<T> type)
      Convert the value to the given type.
      Type Parameters:
      T - The generic type
      Parameters:
      value - The value
      type - The type
      Returns:
      The converted value
      Throws:
      DataAccessException - if the value cannot be converted
    • getRequiredValue

      <T> @Nullable T getRequiredValue(RS resultSet, IDX name, Class<T> type) throws DataAccessException
      Get a value from the given result set for the given name and type.
      Type Parameters:
      T - The generic type
      Parameters:
      resultSet - The result set
      name - The name
      type - The type
      Returns:
      The value
      Throws:
      DataAccessException - if the value cannot be read
    • getRequiredValueNonNull

      default <T> T getRequiredValueNonNull(RS resultSet, IDX name, Class<T> type) throws DataAccessException
      Get a value from the given result set for the given name and type.
      Type Parameters:
      T - The generic type
      Parameters:
      resultSet - The result set
      name - The name
      type - The type
      Returns:
      The value
      Throws:
      DataAccessException - if the value cannot be read
    • next

      boolean next(RS resultSet)
      Move the index to the next result if possible.
      Parameters:
      resultSet - The result set
      Returns:
      The next result
    • findColumnIndex

      default int findColumnIndex(RS resultSet, String columnName)
      Resolves the ordinal of the column with the given name in the result set, so that callers can cache it and read the values of subsequent rows by index using getColumnIndexReader() instead of resolving the column name for every row.

      The returned ordinal is only valid for the given result set and uses the index convention of the underlying driver (for example 1-based for JDBC). Readers that cannot resolve column ordinals return -1, in which case callers must keep reading by name.

      Parameters:
      resultSet - The result set
      columnName - The column name
      Returns:
      The column index or -1 if the column cannot be resolved
      Since:
      5.2.0
    • getColumnIndexReader

      default @Nullable ResultReader<RS,Integer> getColumnIndexReader()
      The reader capable of reading values by the ordinals resolved by findColumnIndex(Object, String).
      Returns:
      The column index reader or null if reading by column index is not supported
      Since:
      5.2.0
    • columnResolutionKey

      default Object columnResolutionKey(RS resultSet)
      The object the resolved column ordinals belong to, compared by identity by callers that cache them. It is the result set itself when the result set spans every row, which is the case for JDBC. Readers whose result set object is a single row, which is the case for R2DBC, return something shared by the rows of one result, such as the row metadata, so that the ordinals survive from one row to the next.

      Returning a different object per row is safe: the ordinals are then resolved again for each row.

      Parameters:
      resultSet - The result set
      Returns:
      The object the resolved ordinals belong to
      Since:
      5.2.0
    • readDynamic

      default @Nullable Object readDynamic(RS resultSet, IDX index, DataType dataType)
      Read a value dynamically using the result set and the given name and data type.
      Parameters:
      resultSet - The result set
      index - The name
      dataType - The data type
      Returns:
      The value, can be null
      Throws:
      DataAccessException - if the value cannot be read
    • readLong

      default long readLong(RS resultSet, IDX name)
      Read a long value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The long value
    • readChar

      default char readChar(RS resultSet, IDX name)
      Read a char value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The char value
    • readDate

      default @Nullable Date readDate(RS resultSet, IDX name)
      Read a date value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The char value
    • readDuration

      default @Nullable Duration readDuration(RS resultSet, IDX name)
      Read a duration value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The duration value
      Since:
      5.0
    • readPeriod

      default @Nullable Period readPeriod(RS resultSet, IDX name)
      Read a period value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The period value
      Since:
      5.0
    • readTimestamp

      default @Nullable Date readTimestamp(RS resultSet, IDX index)
      Read a timestamp value for the given index.
      Parameters:
      resultSet - The result set
      index - The index (such as the column name)
      Returns:
      The char value
    • readTime

      default @Nullable Time readTime(RS resultSet, IDX index)
      Read a time value for the given index.
      Parameters:
      resultSet - The result set
      index - The index (such as the column name)
      Returns:
      The char value
    • readString

      default @Nullable String readString(RS resultSet, IDX name)
      Read a string value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The string value
    • readUUID

      default @Nullable UUID readUUID(RS resultSet, IDX name)
      Read a UUID value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The string value
    • readInt

      default int readInt(RS resultSet, IDX name)
      Read an int value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The int value
    • readBoolean

      default boolean readBoolean(RS resultSet, IDX name)
      Read a boolean value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The boolean value
    • readFloat

      default float readFloat(RS resultSet, IDX name)
      Read a float value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The float value
    • readByte

      default byte readByte(RS resultSet, IDX name)
      Read a byte value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The byte value
    • readShort

      default short readShort(RS resultSet, IDX name)
      Read a short value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The short value
    • readDouble

      default double readDouble(RS resultSet, IDX name)
      Read a double value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The double value
    • readBigDecimal

      default @Nullable BigDecimal readBigDecimal(RS resultSet, IDX name)
      Read a BigDecimal value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The BigDecimal value
    • readBytes

      default byte @Nullable [] readBytes(RS resultSet, IDX name)
      Read a byte[] value for the given name.
      Parameters:
      resultSet - The result set
      name - The name (such as the column name)
      Returns:
      The byte[] value
    • getConversionService

      default io.micronaut.core.convert.ConversionService getConversionService()
      Get conversion service.
      Returns:
      the instance of ConversionService