createConnection
Controls whether the generated code should create/open connection itself or use a given connection.
A method either takes a connection from the repository’s DataSource and closes it when it
is done, or takes a java.sql.Connection as its first parameter and leaves it open for
whoever passed it in.
With generateConnectionOverloads left on — it is on by default — you get both and this setting decides nothing you have to think about. It matters when you turn overloads off and want one shape rather than the other.
Configuration Options
Option: ’true'
The default. The method opens a connection and closes it:
public final class SomeRepository {
public List<Tenant> findTenants() {
try (final var connection = dataSource.getConnection()) {
// ... rest of generated code
}
}
}
Option: ‘false’
The connection comes from the caller, so the statement can join work already in progress:
public final class SomeRepository {
public List<Tenant> findTenants(final Connection connection) {
// ... rest of generated code
}
}
Related Options
Also in this group: annotations , catchAndRethrow , description , executeBatch , executeOnce , generateConnectionOverloads , generateResultRowType , injectConverter , 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:
-- createConnection: true
SELECT something
FROM your_database_schema
WHERE some_column = :some_value