resultRowType
The fully-qualified name of a record to build each result row into
Name a record and YoSQL writes the converter for you. It reads the record’s canonical
constructor out of its source file — under sourceDirectory
— and
emits one resultSet.getX(...) call per component, in a class of its own. No reflection is
involved at any point, so the result survives a GraalVM native image intact.
A component takes its column from its own name, camelCase read as snake_case: tenantId
reads the tenant_id column. When a column is named something else, alias it in the SQL —
select amount_cents as minor_units — which keeps the mapping next to the query that produces
it.
Components whose own type is a record are built from the same flat row: nesting groups values on the Java side and the query knows nothing about it, so a nested component claims the column matching its own name, not a prefixed one.
A type the generator cannot otherwise read works if it says how: a static factory called
valueOf, taking one value the generator does know, is called with the column’s value. That is
the same convention enums follow, and it is what makes a one-component record a value wrapped
around a column rather than a nesting.
A column no component claims, or a component no column supplies, fails the build and names the file, the statement and the component.
Configuration Options
Related Options
annotations : The additional annotations to be placed on generated methods.
catchAndRethrow : Catch exceptions during SQL execution and re-throw them as RuntimeExceptions
createConnection : Controls whether the generated code should create/open connection itself or use a given connection.
description : The description for the SQL statement
executeBatch : Generate methods that are executed as batch
executeBatchPrefix : The method prefix to use for generated methods that execute in a batch.
executeBatchSuffix : The method suffix to use for generated methods that execute in a batch.
executeOnce : Generate methods that are executed once with the given parameters
executeOncePrefix : The method prefix to use for generated methods that execute once.
executeOnceSuffix : The method suffix to use for generated methods that execute once.
name : The name of the SQL statement
parameters : The parameters of the SQL statement.
repository : The fully qualified name of the target repository class.
resultRowColumns : Overrides which column a component of the result row type reads
resultRowConverter : The fully-qualified name of the converter class to use
returningMode : The returning mode of the SQL statement.
throwOnMultipleResults : Throw an exception in case a statement using
ReturningMode.SINGLEproduces more than 1 result.type : The type of the SQL statement.
vendor : The vendor name of the database the SQL statement is intended for
writesReturnUpdateCount : Writing method which are using
ReturningMode.NONEreturn the number of affected rows instead.
Front Matter
In order to configure this option, place the following code in the front matter of your SQL statement:
-- resultRowType: configValue
SELECT something
FROM your_database_schema
WHERE some_column = :some_value