remove ilo run command file
[yosql.git] / yosql-website / content / configuration / repositories / injectConverters.md
blob90742be32a09170dbf7ed474eedb37c8831a4086
1 ---
2 title: injectConverters
3 date: 2019-09-27T18:51:08+02:00
4 menu:
5   main:
6     parent: Repositories
7 categories:
8   - Configuration
9 tags:
10   - repositories
11   - converters
12   - dependency injection
13 ---
15 Toggles whether converters are exposed as constructor parameters and created by `YoSQL` using the default constructor of a converter. Defaults to `false`.
17 ## Configuration Options
19 ### Option: 'false'
21 The default value of the `injectConverters` configuration option is `false`. Setting the option to `false` therefore produces the same code generated as the default configuration without any configuration option set. It produces code similar to this:
23 ```java
24 package com.example.persistence;
26 public class SomeRepository {
28     private final DataSource dataSource;
30     private final ToResultRowConverter resultRow;
32     public SomeRepository(final DataSource dataSource) {
33         this.dataSource = dataSource;
34         this.resultRow = new ToResultRowConverter();
35     }
36     
37     // ... rest of generated code
40 ```
42 ### Option: 'true'
44 Changing the `injectConverters` configuration option to `true` generates the following code instead:
46 ```java
47 package your.own.domain;
49 public class SomeRepository {
51     private final DataSource dataSource;
53     private final ToResultRowConverter resultRow;
55     public SomeRepository(final DataSource dataSource, final ToResultRowConverter resultRow) {
56         this.dataSource = dataSource;
57         this.resultRow = resultRow;
58     }
60     // ... rest of generated code
61     
63 ```
65 ## Related Options
67 - [allowedCallPrefixes](../allowedcallprefixes/): Controls which method name prefixes are allowed for calling statements.
68 - [allowedReadPrefixes](../allowedreadprefixes/): Controls which method name prefixes are allowed for reading statements.
69 - [allowedWritePrefixes](../allowedwriteprefixes/): Controls which method name prefixes are allowed for writing statements.
70 - [basePackageName](../basepackagename/): Controls the base package name for generated repositories.
71 - [validateMethodNamePrefixes](../validatemethodnameprefixes/): Controls whether method name prefixes are validated.
73 ## Tooling
75 ### Maven
77 In order to use `YoSQL` together with [Maven](https://maven.apache.org/), take a look at the tooling [documentation for Maven](/tooling/maven/).
79 {{< maven/config/repositories/injectConverters >}}
81 ### Gradle
83 In order to use `YoSQL` together with [Gradle](https://gradle.org/), take a look at the tooling [documentation for Gradle](/tooling/gradle/).
85 ```kotlin
86 plugins {
87   java
88   id("wtf.metio.yosql") version "2021.4.21"
91 yosql {
92   repositories {
93     injectConverters.set(true)
94   }
96 ```
98 ```groovy
99 plugins {
100   id "java"
101   id "wtf.metio.yosql" version "2021.4.21"
104 yosql {
105   repositories {
106     injectConverters = true
107   }
111 ### Bazel
113 In order to use `YoSQL` together with [Bazel](https://bazel.build/), take a look at the tooling [documentation for Bazel](/tooling/bazel/).
115 ### CLI
117 In order to use YoSQL on the command line, take a look at the tooling [documentation for CLI](/tooling/cli/).
119 ```shell
120 $ yosql --repositories-inject-converters=true
123 The shorter form is available as well:
125 ```shell
126 $ yosql --inject-converters=true