generateInterfaces

Talks about:

Generate interfaces for all repositories

Writes an interface next to each repository, declaring the same methods, and has the repository implement it. Depend on the interface and the class it is implemented by becomes something you can substitute — a stub in a test, a caching decorator, a fake that never touches a database.

The interface is the repository without the Repository that made it one, so a TenantRepository implements a Tenant. Where there is no suffix to drop — a repository you named yourself — the interface takes an I in front instead, which is what keeps the two names apart.

Configuration Options

Option: ‘false’

The default. A repository is a class and nothing else:

package com.example.persistence;

public final class TenantRepository {

    // ... rest of generated code

}

Option: ’true'

The repository implements an interface your code can depend on instead:

package com.example.persistence;

public interface Tenant {

    Optional<Tenant> findTenant(UUID id);

}

public final class TenantRepository implements TenantRepositoryApi {

    // ... rest of generated code

}

Also in this group: allowedCallPrefixes , allowedReadPrefixes , allowedWritePrefixes , basePackageName , catchAndRethrow , createConnection , executeBatch , executeOnce , generateConnectionOverloads , injectConverters , 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-interfaces=configValue

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

yosql --generate-interfaces=configValue

Gradle

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

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

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

or in Groovy syntax like this:

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

yosql {
  repositories {
    generateInterfaces = configValue
  }
}

Maven

In order to use YoSQL together with Maven , take a look at the tooling documentation for Maven . The generateInterfaces 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>
          <generateInterfaces>configValue</generateInterfaces>
        </repositories>
      </configuration>
    </plugin>
  </plugins>
</build>