generateConnectionOverloads

Talks about:

Generate both a DataSource-based method and a Connection-taking overload for every statement.

Whether a statement gets its connection from the repository’s DataSource or from the caller is not a property of the statement — it is what the call site needs. One caller reads a tenant on its own; another reads it as part of a transaction it already opened. So every statement generates both, as overloads of one name:

Optional<Tenant> findTenant(UUID id);
Optional<Tenant> findTenant(Connection connection, UUID id);

The Connection overload runs the statement on the connection it is given and does not close it, which is what lets several statements share a transaction — see transactions .

Turning this off generates only the shape createConnection selects, one method per statement.

Configuration Options

Option: ’true'

The default. Each statement is reachable both ways:

public final class TenantRepository {

    public Optional<Tenant> findTenant(final UUID id) {
        try (final var connection = dataSource.getConnection()) {
            return findTenant(connection, id);
        }
        // ... rest of generated code
    }

    public Optional<Tenant> findTenant(final Connection connection, final UUID id) {
        // ... rest of generated code
    }

}

Option: ‘false’

Only the shape createConnection asks for is generated:

public final class TenantRepository {

    public Optional<Tenant> findTenant(final UUID id) {
        // ... rest of generated code
    }

}

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

Front Matter

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

-- generateConnectionOverloads: configValue
SELECT  something
FROM    your_database_schema
WHERE   some_column = :some_value