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: allowedCallPrefixes , allowedReadPrefixes , allowedWritePrefixes , basePackageName , catchAndRethrow , createConnection , executeBatch , executeBatchPrefix , executeBatchSuffix , executeOnce , executeOncePrefix , executeOnceSuffix , generateInterfaces , injectConverters , repositoryInterfacePrefix , repositoryInterfaceSuffix , repositoryNamePrefix , repositoryNameSuffix , throwOnMultipleResults , validateMethodNamePrefixes , writesReturnUpdateCount .

Tooling

Ant

In order to use YoSQL together with Ant , take a look at the tooling documentation for Ant .

Bazel

In order to use YoSQL together with Bazel , take a look at the tooling documentation for Bazel .

CLI

In order to use YoSQL on the command line, take a look at the tooling documentation for CLI .

yosql --repositories-generate-connection-overloads=configValue

As long as the name of the config option is unique across all configuration groups, you can use the shorter form:

yosql --generate-connection-overloads=configValue

Gradle

In order to use YoSQL together with Gradle , take a look at the tooling documentation for Gradle . The generateConnectionOverloads setting can be configured using Gradle in Kotlin syntax like this:

plugins {
  java
  id("wtf.metio.yosql") version "2023.2.22"
}

yosql {
  repositories {
    generateConnectionOverloads.set(configValue)
  }
}

or in Groovy syntax like this:

plugins {
  id "java"
  id "wtf.metio.yosql" version "2023.2.22"
}

yosql {
  repositories {
    generateConnectionOverloads = configValue
  }
}

Maven

In order to use YoSQL together with Maven , take a look at the tooling documentation for Maven . The generateConnectionOverloads setting can be configured using Maven like this:

<build>
  <plugins>
    <plugin>
      <groupId>wtf.metio.yosql</groupId>
      <artifactId>yosql-tooling-maven</artifactId>
      <version>2023.2.22</version>
      <configuration>
        <repositories>
          <generateConnectionOverloads>configValue</generateConnectionOverloads>
        </repositories>
      </configuration>
    </plugin>
  </plugins>
</build>