type
The type of the SQL statement.
Whether a statement reads, writes, or calls a stored procedure. It decides what is generated for it, and it is normally not written at all: the statement’s name settles it.
A name beginning with one of the
read prefixes
is reading, one of the
write prefixes
is writing, and one of the
call prefixes
is calling. YoSQL does not
parse your SQL to work this out, and it does not need to.
Set it where you want a name the prefixes do not cover — a countTenants that reads, a
purgeTenants that writes. A statement whose name matches no prefix and which sets no
type fails the build rather than quietly generating nothing.
Configuration Options
Option: ‘reading’
Runs the statement as a query and maps what comes back:
public final class TenantRepository {
public List<Tenant> countTenants() {
// ... rest of generated code
}
}
Option: ‘writing’
Runs the statement as an update, and generates a batch method alongside:
public final class TenantRepository {
public int purgeTenants(final Instant before) {
// ... rest of generated code
}
public int[] purgeTenantsBatch(final Instant[] before) {
// ... rest of generated code
}
}
Option: ‘calling’
Runs the statement as a CallableStatement, for a stored procedure:
public final class TenantRepository {
public List<Tenant> rebuildTenantIndex() {
// ... rest of generated code
}
}
Related Options
Also in this group: annotations , catchAndRethrow , createConnection , description , executeBatch , executeOnce , generateConnectionOverloads , generateResultRowType , name , parameters , repository , resultRowColumns , resultRowConverter , resultRowType , returningMode , throwOnMultipleResults , validateSchema , vendor , writesReturnUpdateCount .
Front Matter
In order to configure this option, place the following code in the front matter of your SQL statement:
-- type: reading
SELECT something
FROM your_database_schema
WHERE some_column = :some_value