Skip to content

✅ JDBC select

  • @JdbcSelect define a method which will execute SQL selects like
    • create prepareStatement
    • fill parameter from the method
    • configure statement
    • execute and process the ResultSet
  • the value of @JdbcSelect must contain a valid SQL select statement with named parameters (:name) as described in param binding
  • Return types must be non-void and must be either
    • primitive
    • a column Java type
    • a row Java type
    • one of, where T may be a primitve, a column Java type or a row Java type
      • List<T>
      • Stream<T>
      • JdbcIterable<T> (which is defacto a Iterable<T> with AutoCloseable support)
      • JdbcResultSet
  • Result types are mapped as described in result mapping.
  • Parameter types are mapped as described in param binding.
  • Converters are searched as described in converter lookup.
  • null handling as described in null check support.
  • Return types are primitives, column or row Java type
    • For column Java type we map always the first columns
  • Supported annotations:
    • if column Java type: @JdbcName: define the name of the column to use the value from
    • @JdbcConverterName: define a specific converter
    • @JdbcNoRows: define the behavior in case no rows are returned
      • JdbcNoRows.THROW_EXCEPTION: a JdbcEmptyResultSetException is thrown
      • JdbcNoRows.RETURN_NULL:
        • return null if the return type is nullable/unspecific
        • return Optional.EMPTY if the return type is Optional
        • throws JdbcEmptyResultSetException if return type is nonnull
    • @JdbcNoMoreRows: define the behavior in case more than a row is returned
      • JdbcNoMoreRows.THROW_EXCEPTION:
        • a JdbcUnexpectedRowException is thrown
        • ✅ the max rows return by the statement is set to two, e.g. stmt.setFetchSize(2)
      • JdbcNoMoreRows.IGNORE:
        • the other rows are ignored
        • ✅ the max rows return by the statement is set to one, e.g. stmt.setFetchSize(1)
  • The default behavior is JdbcNoRows.THROW_EXCEPTION and JdbcNoMoreRows.THROW_EXCEPTION
  • ✅ Java Optional is supported
  • ✅ List of primitives, column or row Java type
    • For column Java type we map always the first columns
  • ✅ The column type is mapped to the first column of the result set
    • ✅ column Java types can be mapped to a different column with @JdbcName
  • Supported annotations:
    • ✅ if column Java type: @JdbcName: define the name of the column to use the value from
    • @JdbcNoRows: is not supported
    • @JdbcNoMoreRows: is not supported
  • ✅ Java Optional is supported for column Java types
  • ✅ List of primitives, column or row Java type
    • For column Java type we map always the first columns
  • ✅ The column type is mapped to the first column of the result set
    • ✅ column Java types can be mapped to a different column with @JdbcName
  • Supported annotations:
    • ✅ if column Java type: @JdbcName: define the name of the column to use the value from
    • @JdbcNoRows: is not supported
    • @JdbcNoMoreRows: is not supported
  • ✅ Java Optional is supported for column Java types
  • ✅ JdbcIterator of primitives, column or row Java type
    • For column Java type we map always the first columns
  • ✅ The column type is mapped to the first column of the result set
    • ✅ column Java types can be mapped to a different column with @JdbcName
  • Supported annotations:
    • ✅ if column Java type: @JdbcName: define the name of the column to use the value from
    • @JdbcNoRows: is not supported
    • @JdbcNoMoreRows: is not supported
  • ✅ Java Optional is supported for column Java types
  • ✅ JdbcResultSet of primitives, column or row Java type
    • For column Java type we map always the first columns
  • ✅ The column type is mapped to the first column of the result set
    • ✅ column Java types can be mapped to a different column with @JdbcName
  • Supported annotations:
    • ✅ if column Java type: @JdbcName: define the name of the column to use the value from
    • @JdbcNoRows: is not supported
    • @JdbcNoMoreRows: is not supported
  • ✅ Java Optional is supported for column Java types