Interface ResultReader<RS,IDX>
- Type Parameters:
RS- The result setIDX- 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 TypeMethodDescriptiondefault ObjectcolumnResolutionKey(RS resultSet) The object the resolved column ordinals belong to, compared by identity by callers that cache them.default <T> TconvertRequired(Object value, io.micronaut.core.type.Argument<T> type) Convert the value to the given type.default <T> TconvertRequired(Object value, Class<T> type) Convert the value to the given type.default intfindColumnIndex(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 usinggetColumnIndexReader()instead of resolving the column name for every row.default @Nullable ResultReader<RS, Integer> The reader capable of reading values by the ordinals resolved byfindColumnIndex(Object, String).default io.micronaut.core.convert.ConversionServiceGet conversion service.<T> @Nullable TgetRequiredValue(RS resultSet, IDX name, Class<T> type) Get a value from the given result set for the given name and type.default <T> TgetRequiredValueNonNull(RS resultSet, IDX name, Class<T> type) Get a value from the given result set for the given name and type.booleanMove the index to the next result if possible.default @Nullable BigDecimalreadBigDecimal(RS resultSet, IDX name) Read a BigDecimal value for the given name.default booleanreadBoolean(RS resultSet, IDX name) Read a boolean value for the given name.default byteRead a byte value for the given name.default byte @Nullable []Read a byte[] value for the given name.default charRead a char value for the given name.default @Nullable DateRead a date value for the given name.default doublereadDouble(RS resultSet, IDX name) Read a double value for the given name.default @Nullable DurationreadDuration(RS resultSet, IDX name) Read a duration value for the given name.default @Nullable ObjectreadDynamic(RS resultSet, IDX index, DataType dataType) Read a value dynamically using the result set and the given name and data type.default floatRead a float value for the given name.default intRead an int value for the given name.default longRead a long value for the given name.default @Nullable PeriodreadPeriod(RS resultSet, IDX name) Read a period value for the given name.default shortRead a short value for the given name.default @Nullable StringreadString(RS resultSet, IDX name) Read a string value for the given name.default @Nullable TimeRead a time value for the given index.default @Nullable DatereadTimestamp(RS resultSet, IDX index) Read a timestamp value for the given index.default @Nullable UUIDRead a UUID value for the given name.
-
Method Details
-
convertRequired
Convert the value to the given type.- Type Parameters:
T- The generic type- Parameters:
value- The valuetype- The type- Returns:
- The converted value
- Throws:
DataAccessException- if the value cannot be converted
-
convertRequired
Convert the value to the given type.- Type Parameters:
T- The generic type- Parameters:
value- The valuetype- The type- Returns:
- The converted value
- Throws:
DataAccessException- if the value cannot be converted
-
getRequiredValue
Get a value from the given result set for the given name and type.- Type Parameters:
T- The generic type- Parameters:
resultSet- The result setname- The nametype- 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 setname- The nametype- The type- Returns:
- The value
- Throws:
DataAccessException- if the value cannot be read
-
next
Move the index to the next result if possible.- Parameters:
resultSet- The result set- Returns:
- The next result
-
findColumnIndex
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 usinggetColumnIndexReader()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 setcolumnName- The column name- Returns:
- The column index or
-1if the column cannot be resolved - Since:
- 5.2.0
-
getColumnIndexReader
The reader capable of reading values by the ordinals resolved byfindColumnIndex(Object, String).- Returns:
- The column index reader or
nullif reading by column index is not supported - Since:
- 5.2.0
-
columnResolutionKey
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
Read a value dynamically using the result set and the given name and data type.- Parameters:
resultSet- The result setindex- The namedataType- The data type- Returns:
- The value, can be null
- Throws:
DataAccessException- if the value cannot be read
-
readLong
-
readChar
-
readDate
-
readDuration
-
readPeriod
-
readTimestamp
-
readTime
-
readString
-
readUUID
-
readInt
-
readBoolean
-
readFloat
-
readByte
-
readShort
-
readDouble
-
readBigDecimal
Read a BigDecimal value for the given name.- Parameters:
resultSet- The result setname- The name (such as the column name)- Returns:
- The BigDecimal value
-
readBytes
-
getConversionService
default io.micronaut.core.convert.ConversionService getConversionService()Get conversion service.- Returns:
- the instance of
ConversionService
-