Skip to content

Processor Configuration

The annotation processor can be configured with annotation processor options or with one type annotated with @JdbcConfig. The annotation processor itself supports Java 17 or newer.

OptionsDescriptionDefault
io.kaumei.jdbc.processor.configA fully qualified @JdbcConfig type.unset
io.kaumei.jdbc.processor.debugfolderThe folder for annotation processor debug output.unset
io.kaumei.jdbc.processor.loglevelThe annotation processor log level.ERROR
  • If io.kaumei.jdbc.processor.config is set, it must point to a type annotated with @JdbcConfig. The value must be the fully qualified type name. Invalid values are rejected by the annotation processor. This option is useful when incremental compilation prevents automatic discovery of the configuration type.
  • If io.kaumei.jdbc.processor.debugfolder is set, the annotation processor dumps its internal state to that folder. This is useful for debug sessions.
  • io.kaumei.jdbc.processor.loglevel changes the annotation processor log level. Supported values are: ERROR, WARN, INFO, DEBUG.

The annotation processor can be configured by annotating a type with @JdbcConfig or by an annotation processor option (see above). This type defines default values for the annotation processor run.

@JdbcConfig may be placed on a class or on a pure configuration interface. It must not be placed on a JDBC service interface that declares @JdbcSelect, @JdbcUpdate, @JdbcBatchUpdate, or @JdbcNative methods.

AnnotationDefaultValue rangeUnset supportDynamic support
@JdbcBatchSize1000>= 1noyes
@JdbcFetchDirectionunsetenumyesyes
@JdbcFetchSizeunset>= 0yesyes
@JdbcMaxRowsunset>= 0yesyes
@JdbcNoMoreRowsTHROW_EXCEPTIONenumnono
@JdbcNoRowsTHROW_EXCEPTIONenumnono
@JdbcQueryTimeoutunset>= 0yesyes
@JdbcResultSetConcurrencyunsetenumyesyes
@JdbcResultSetTypeunsetenumyesyes
@JdbcConfig.generatedClassSuffixJdbcsuffixnono
@JdbcConfig.maxCollectionPlaceholders1000>= 1nono
@JdbcConfig.maxTotalPlaceholders2000>= 1nono
@JdbcConfig.returnGeneratedValuesGENERATED_KEYSenumnono

Annotations with unset support can suppress an inherited value when used without an explicit value. For example, @JdbcQueryTimeout() on a method suppresses a timeout inherited from the interface or configuration type.

Configuration annotations can define constant values on a configuration type, JDBC interface, or JDBC method. Some configuration annotations can also be placed on one method parameter. In that form, the value is supplied by the caller at runtime and overrides constant values for that method call.

Dynamic parameter values are method-local. They do not change the selected @JdbcConfig, interface-level configuration, or method-level constant annotations.

Only annotations whose Java target includes PARAMETER support dynamic parameter values. For example, @JdbcBatchSize may be placed on an @JdbcBatchUpdate method for a constant batch size or on one method parameter for a runtime batch size. Integer option values outside their value range are rejected by the annotation processor for constant values and by the generated method for dynamic values. For annotations with unset support, the static -1 sentinel remains valid as the unset value. For @JdbcQueryTimeout, @JdbcFetchSize, and @JdbcMaxRows, 0 keeps the JDBC meaning of no timeout, driver default, or no row limit.

@JdbcConfig.generatedClassSuffix defines the suffix used for generated implementation classes. The default keeps the generated class name InterfaceNameJdbc. For example, generatedClassSuffix = "Impl" generates InterfaceNameImpl. The suffix must be a non-blank Java class name suffix. Invalid suffix values are processor errors.

@JdbcConfig.maxCollectionPlaceholders limits one dynamic array or List expansion created by :param.{values} or :param.*. The default is 1000. Values above the configured limit are rejected by the generated method with JdbcException.

@JdbcConfig.maxTotalPlaceholders limits the total number of JDBC ? placeholders in one generated method call. The default is 2000. The total includes plain :param markers, statically known record value expansion, and dynamically expanded array or List elements. When array or List values determine the final total at runtime, violations are rejected by the generated method with JdbcException.

❗️@JdbcQueryTimeout ❗️@JdbcQueryTimeout ❗️@JdbcQueryTimeout ❗️JdbcBatchSize ❗️JdbcQueryTimeout ❗️JdbcConfig.returnGeneratedValues ❗️JdbcConfig.returnGeneratedValues

With @JdbcConfig(parent = ...) one parent configuration can be defined. Parent configuration is applied before child configuration. The child configuration overrides the parent configuration.

Static methods inside the configuration type are global converters when they are annotated with either @JdbcToJava or @JavaToJdbc.

@JdbcConfig(converter = {...}) adds additional global converter types. For each referenced type, methods explicitly annotated with @JdbcToJava or @JavaToJdbc are included in converter lookup.

❗️@ConfigSpec.parent ❗️@ConfigSpec.converter ❗️@ConfigSpec.converter ❗️@ConfigSpec.converter

Each module that runs the annotation processor should define its own @JdbcConfig or explicitly select one with io.kaumei.jdbc.processor.config.

The selected configuration type is the module boundary for processor configuration. All types referenced from that configuration, including parent configurations and converter classes, must be visible during annotation processing for that module.

A shared module may provide a configuration type or converter classes. The processing module must reference the shared configuration or converters explicitly from its selected configuration.