✅ JDBC select
@JdbcSelectdefine a method which will execute SQL selects like- create
prepareStatement - fill parameter from the method
- configure statement
- execute and process the
ResultSet
- create
- the
valueof@JdbcSelectmust 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 aIterable<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 a column/row Java type
Section titled “✅ Return a column/row Java type”- 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 returnedJdbcNoRows.THROW_EXCEPTION: aJdbcEmptyResultSetExceptionis thrownJdbcNoRows.RETURN_NULL:- return
nullif the return type is nullable/unspecific - return
Optional.EMPTYif the return type is Optional - throws
JdbcEmptyResultSetExceptionif return type is nonnull
- return
@JdbcNoMoreRows: define the behavior in case more than a row is returnedJdbcNoMoreRows.THROW_EXCEPTION:- a
JdbcUnexpectedRowExceptionis thrown - ✅ the max rows return by the statement is set to two, e.g.
stmt.setFetchSize(2)
- a
JdbcNoMoreRows.IGNORE:- the other rows are ignored
- ✅ the max rows return by the statement is set to one, e.g.
stmt.setFetchSize(1)
- if column Java type:
- The default behavior is
JdbcNoRows.THROW_EXCEPTIONandJdbcNoMoreRows.THROW_EXCEPTION - ✅ Java Optional is supported
✅ Return List
Section titled “✅ Return List”- ✅ 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
- ✅ if column Java type:
- ✅ Java Optional is supported for column Java types
✅ Return Stream
Section titled “✅ Return Stream”- ✅ 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
- ✅ if column Java type:
- ✅ Java Optional is supported for column Java types
✅ Return JdbcIterable
Section titled “✅ Return JdbcIterable”- ✅ 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
- ✅ if column Java type:
- ✅ Java Optional is supported for column Java types
✅ Return JdbcResultSet
Section titled “✅ Return JdbcResultSet”- ✅ 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
- ✅ if column Java type:
- ✅ Java Optional is supported for column Java types