generateResultRowType

Talks about: , and

Write the record this statement builds its rows into.

Everything the record needs is already known — which columns the statement selects, what each one holds, whether it can be null — so naming a record that does not exist yet and setting this writes it for you, next to the converter that builds it.

-- name: findTenant
-- returning: single
-- resultRowType: com.example.domain.Tenant
-- generateResultRowType: true
select id, slug, created_at from tenant

Opt in per statement rather than whenever the record is missing. A resultRowType naming a record that is not there is far more often a typo than a request, and writing a new record for a misspelled name would replace a build error with a mystery.

It needs a schema it can read, and it needs every selected column to be one the catalog describes with a type it maps. Where any of that is missing the record is not written, and the statement fails as it would have before — because half a record is worse than none.

The record it writes is yours to take over: copy it into your own sources, drop the setting, and nothing else changes.

Also in this group: annotations , catchAndRethrow , createConnection , description , executeBatch , executeOnce , generateConnectionOverloads , name , parameters , repository , resultRowColumns , resultRowConverter , resultRowType , returningMode , throwOnMultipleResults , type , validateSchema , vendor , writesReturnUpdateCount .

Front Matter

In order to configure this option, place the following code in the front matter of your SQL statement:

-- generateResultRowType: true
SELECT  something
FROM    your_database_schema
WHERE   some_column = :some_value