catchAndRethrow
Catch exceptions during SQL execution and re-throw them as RuntimeExceptions
Configuration Options
Option: ’true'
The default value for catchAndRethrow
is true
. This will catch any SQLException
that happen during SQL execution and re-throw them as RuntimeExceptions
.
package com.example.persistence;
public class SomeRepository {
public void writeSome() {
// ... some code
}
// ... rest of generated code
}
Option: ‘false’
In case you want to handle SQLException
s yourself, set catchAndRethrow
to false
.
package com.example.persistence;
import java.sql.SQLException;
public class SomeRepository {
public void writeSome() throws SQLException {
// ... some code
}
// ... rest of generated code
}
Related Options
- allowedCallPrefixes: Configures which name prefixes are allowed for statements that are calling stored procedures.
- allowedReadPrefixes: Configures which name prefixes are allowed for statements that are reading data from your database.
- allowedWritePrefixes: Configures which name prefixes are allowed for statements that are writing data to your database.
- basePackageName: The base package name for all repositories
- createConnection: Controls whether the generated code should create/open connection itself or use a given connection.
- executeBatch: Generate methods that are executed as batch
- executeBatchPrefix: The method prefix to use for generated methods that execute in a batch.
- executeBatchSuffix: The method suffix to use for generated methods that execute in a batch.
- executeOnce: Generate methods that are executed once with the given parameters
- executeOncePrefix: The method prefix to use for generated methods that execute once.
- executeOnceSuffix: The method suffix to use for generated methods that execute once.
- generateInterfaces: Generate interfaces for all repositories
- injectConverters: Toggles whether converters should be injected as constructor parameters.
- repositoryInterfacePrefix: The repository interface name prefix to use.
- repositoryInterfaceSuffix: The repository interface name suffix to use.
- repositoryNamePrefix: The repository name prefix to use.
- repositoryNameSuffix: The repository name suffix to use.
- throwOnMultipleResults: Throw an exception in case a statement using
ReturningMode.SINGLE
produces more than 1 result. - validateMethodNamePrefixes: Validate user given names against list of allowed prefixes per type.
- writesReturnUpdateCount: Writing method which are using
ReturningMode.NONE
return the number of affected rows instead.
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-catch-and-rethrow=configValue
As long as the name of the config option is unique across all configuration groups, you can use the shorter form:
$ yosql --catch-and-rethrow=configValue
Gradle
In order to use YoSQL
together with Gradle, take a look at the tooling documentation for Gradle. The catchAndRethrow
setting can be configured using Gradle in Kotlin syntax like this:
plugins {
java
id("wtf.metio.yosql") version "2023.2.22"
}
yosql {
repositories {
catchAndRethrow.set(configValue)
}
}
or in Groovy syntax like this:
plugins {
id "java"
id "wtf.metio.yosql" version "2023.2.22"
}
yosql {
repositories {
catchAndRethrow = configValue
}
}
Maven
In order to use YoSQL
together with Maven, take a look at the tooling documentation for Maven. The catchAndRethrow
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>
<catchAndRethrow>configValue</catchAndRethrow>
</repositories>
</configuration>
</plugin>
</plugins>
</build>