[#7846] Document the fact that <forcedType/> converters can be Java code
This commit is contained in:
parent
872529acdf
commit
2c6cbeebb3
@ -16311,6 +16311,72 @@ public class CaseInsensitiveOrderProvider implements Comparator<Definition> {
|
||||
For more information about using converters, <reference id="custom-data-types" title="please refer to the manual's section about custom data type conversion"/>.
|
||||
</p>
|
||||
|
||||
<h3>Mapping to user type with an inline converter</h3>
|
||||
|
||||
<p>
|
||||
For convenience, you can inline your converter code directly into the configuration instead of providing a class reference.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>XML configuration (standalone and Maven)</strong>
|
||||
</p>
|
||||
|
||||
</html><xml><![CDATA[<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-{codegen-xsd-version}.xsd">
|
||||
<generator>
|
||||
<database>
|
||||
<!-- The first matching forcedType will be applied to the data type definition. -->
|
||||
<forcedTypes>
|
||||
<forcedType>
|
||||
|
||||
<!-- Specify the Java type of your custom type. This corresponds to the Converter's <U> type. -->
|
||||
<userType>com.example.MyEnum</userType>
|
||||
|
||||
<!-- Associate that custom type with your inline converter. -->
|
||||
<converter>org.jooq.Converter.ofNullable(Integer.class, MyEnum.class, i -> MyEnum.values()[i], MyEnum::ordinal)</converter>
|
||||
|
||||
<!-- These are the same as for type rewriting -->
|
||||
<expression>.*\.DATE_OF_.*</expression>
|
||||
<types>.*</types>
|
||||
</forcedType>
|
||||
</forcedTypes>
|
||||
</database>
|
||||
</generator>
|
||||
</configuration>]]></xml><html>
|
||||
|
||||
<p>
|
||||
<strong>Programmatic configuration</strong>
|
||||
</p>
|
||||
|
||||
</html><java><![CDATA[configuration
|
||||
.withGenerator(new Generator(
|
||||
.withDatabase(new Database()
|
||||
// The first matching forcedType will be applied to the data type definition.
|
||||
.withForcedTypes(new ForcedType()
|
||||
.withUserType("com.example.MyEnum")
|
||||
.withConverter("org.jooq.Converter.ofNullable(Integer.class, MyEnum.class, i -> MyEnum.values()[i], MyEnum::ordinal)")
|
||||
.withExpression(".*\.DATE_OF_.*")
|
||||
.withTypes(".*")))));]]></java><html>
|
||||
|
||||
<p>
|
||||
<strong>Gradle configuration</strong>
|
||||
</p>
|
||||
|
||||
</html><java><![CDATA[myConfigurationName(sourceSets.main) {
|
||||
generator {
|
||||
database {
|
||||
// The first matching forcedType will be applied to the data type definition.
|
||||
forcedTypes {
|
||||
forcedType {
|
||||
userType = 'com.example.MyEnum'
|
||||
converter = 'org.jooq.Converter.ofNullable(Integer.class, MyEnum.class, i -> MyEnum.values()[i], MyEnum::ordinal)'
|
||||
expression = '.*\.DATE_OF_.*'
|
||||
types = '.*'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]]></java><html>
|
||||
|
||||
<h3>Mapping to an enum user type with a converter</h3>
|
||||
|
||||
<p>
|
||||
|
||||
@ -16951,6 +16951,72 @@ public class CaseInsensitiveOrderProvider implements Comparator<Definition> {
|
||||
For more information about using converters, <reference id="custom-data-types" title="please refer to the manual's section about custom data type conversion"/>.
|
||||
</p>
|
||||
|
||||
<h3>Mapping to user type with an inline converter</h3>
|
||||
|
||||
<p>
|
||||
For convenience, you can inline your converter code directly into the configuration instead of providing a class reference.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>XML configuration (standalone and Maven)</strong>
|
||||
</p>
|
||||
|
||||
</html><xml><![CDATA[<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-{codegen-xsd-version}.xsd">
|
||||
<generator>
|
||||
<database>
|
||||
<!-- The first matching forcedType will be applied to the data type definition. -->
|
||||
<forcedTypes>
|
||||
<forcedType>
|
||||
|
||||
<!-- Specify the Java type of your custom type. This corresponds to the Converter's <U> type. -->
|
||||
<userType>com.example.MyEnum</userType>
|
||||
|
||||
<!-- Associate that custom type with your inline converter. -->
|
||||
<converter>org.jooq.Converter.ofNullable(Integer.class, MyEnum.class, i -> MyEnum.values()[i], MyEnum::ordinal)</converter>
|
||||
|
||||
<!-- These are the same as for type rewriting -->
|
||||
<expression>.*\.DATE_OF_.*</expression>
|
||||
<types>.*</types>
|
||||
</forcedType>
|
||||
</forcedTypes>
|
||||
</database>
|
||||
</generator>
|
||||
</configuration>]]></xml><html>
|
||||
|
||||
<p>
|
||||
<strong>Programmatic configuration</strong>
|
||||
</p>
|
||||
|
||||
</html><java><![CDATA[configuration
|
||||
.withGenerator(new Generator(
|
||||
.withDatabase(new Database()
|
||||
// The first matching forcedType will be applied to the data type definition.
|
||||
.withForcedTypes(new ForcedType()
|
||||
.withUserType("com.example.MyEnum")
|
||||
.withConverter("org.jooq.Converter.ofNullable(Integer.class, MyEnum.class, i -> MyEnum.values()[i], MyEnum::ordinal)")
|
||||
.withExpression(".*\.DATE_OF_.*")
|
||||
.withTypes(".*")))));]]></java><html>
|
||||
|
||||
<p>
|
||||
<strong>Gradle configuration</strong>
|
||||
</p>
|
||||
|
||||
</html><java><![CDATA[myConfigurationName(sourceSets.main) {
|
||||
generator {
|
||||
database {
|
||||
// The first matching forcedType will be applied to the data type definition.
|
||||
forcedTypes {
|
||||
forcedType {
|
||||
userType = 'com.example.MyEnum'
|
||||
converter = 'org.jooq.Converter.ofNullable(Integer.class, MyEnum.class, i -> MyEnum.values()[i], MyEnum::ordinal)'
|
||||
expression = '.*\.DATE_OF_.*'
|
||||
types = '.*'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]]></java><html>
|
||||
|
||||
<h3>Mapping to an enum user type with a converter</h3>
|
||||
|
||||
<p>
|
||||
|
||||
@ -16995,6 +16995,72 @@ public class CaseInsensitiveOrderProvider implements Comparator<Definition> {
|
||||
For more information about using converters, <reference id="custom-data-types" title="please refer to the manual's section about custom data type conversion"/>.
|
||||
</p>
|
||||
|
||||
<h3>Mapping to user type with an inline converter</h3>
|
||||
|
||||
<p>
|
||||
For convenience, you can inline your converter code directly into the configuration instead of providing a class reference.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>XML configuration (standalone and Maven)</strong>
|
||||
</p>
|
||||
|
||||
</html><xml><![CDATA[<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-{codegen-xsd-version}.xsd">
|
||||
<generator>
|
||||
<database>
|
||||
<!-- The first matching forcedType will be applied to the data type definition. -->
|
||||
<forcedTypes>
|
||||
<forcedType>
|
||||
|
||||
<!-- Specify the Java type of your custom type. This corresponds to the Converter's <U> type. -->
|
||||
<userType>com.example.MyEnum</userType>
|
||||
|
||||
<!-- Associate that custom type with your inline converter. -->
|
||||
<converter>org.jooq.Converter.ofNullable(Integer.class, MyEnum.class, i -> MyEnum.values()[i], MyEnum::ordinal)</converter>
|
||||
|
||||
<!-- These are the same as for type rewriting -->
|
||||
<expression>.*\.DATE_OF_.*</expression>
|
||||
<types>.*</types>
|
||||
</forcedType>
|
||||
</forcedTypes>
|
||||
</database>
|
||||
</generator>
|
||||
</configuration>]]></xml><html>
|
||||
|
||||
<p>
|
||||
<strong>Programmatic configuration</strong>
|
||||
</p>
|
||||
|
||||
</html><java><![CDATA[configuration
|
||||
.withGenerator(new Generator(
|
||||
.withDatabase(new Database()
|
||||
// The first matching forcedType will be applied to the data type definition.
|
||||
.withForcedTypes(new ForcedType()
|
||||
.withUserType("com.example.MyEnum")
|
||||
.withConverter("org.jooq.Converter.ofNullable(Integer.class, MyEnum.class, i -> MyEnum.values()[i], MyEnum::ordinal)")
|
||||
.withExpression(".*\.DATE_OF_.*")
|
||||
.withTypes(".*")))));]]></java><html>
|
||||
|
||||
<p>
|
||||
<strong>Gradle configuration</strong>
|
||||
</p>
|
||||
|
||||
</html><java><![CDATA[myConfigurationName(sourceSets.main) {
|
||||
generator {
|
||||
database {
|
||||
// The first matching forcedType will be applied to the data type definition.
|
||||
forcedTypes {
|
||||
forcedType {
|
||||
userType = 'com.example.MyEnum'
|
||||
converter = 'org.jooq.Converter.ofNullable(Integer.class, MyEnum.class, i -> MyEnum.values()[i], MyEnum::ordinal)'
|
||||
expression = '.*\.DATE_OF_.*'
|
||||
types = '.*'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]]></java><html>
|
||||
|
||||
<h3>Mapping to an enum user type with a converter</h3>
|
||||
|
||||
<p>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user