CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-springframework-boot--spring-boot-starter-jooq

Starter for using jOOQ to access SQL databases with JDBC, providing auto-configuration and Spring integration

Pending
Overview
Eval results
Files

configuration.mddocs/

Configuration

Configuration properties and customization options for jOOQ integration in Spring Boot applications.

Capabilities

JooqProperties

Configuration properties class that maps to spring.jooq.* properties in your application configuration.

/**
 * Configuration properties for jOOQ database library under spring.jooq prefix
 */
@ConfigurationProperties("spring.jooq")
public class JooqProperties {
    
    /** SQL dialect to use. Auto-detected by default. */
    private SQLDialect sqlDialect;
    
    /** Location of the jOOQ config file. */
    private Resource config;
    
    /**
     * Get the configured SQL dialect
     * @return the SQL dialect, or null if auto-detection should be used
     */
    public SQLDialect getSqlDialect();
    
    /**
     * Set the SQL dialect to use
     * @param sqlDialect the SQL dialect
     */
    public void setSqlDialect(SQLDialect sqlDialect);
    
    /**
     * Get the jOOQ configuration file location
     * @return Resource pointing to the config file, or null if not specified
     */
    public Resource getConfig();
    
    /**
     * Set the jOOQ configuration file location
     * @param config Resource pointing to the XML configuration file
     */
    public void setConfig(Resource config);
    
    /**
     * Determine the SQL dialect to use based on configuration and DataSource
     * Uses explicit sqlDialect if set, otherwise auto-detects from DataSource
     * @param dataSource the primary data source
     * @return the SQL dialect to use for the DataSource
     */
    public SQLDialect determineSqlDialect(DataSource dataSource);
}

DefaultConfigurationCustomizer

Functional interface for customizing jOOQ's DefaultConfiguration while retaining auto-configuration benefits.

/**
 * Callback interface for beans that want to customize DefaultConfiguration
 * while keeping default auto-configuration
 */
@FunctionalInterface
public interface DefaultConfigurationCustomizer {
    
    /**
     * Customize the jOOQ Configuration
     * @param configuration the configuration to customize
     */
    void customize(DefaultConfiguration configuration);
}

SqlDialectLookup

Utility class for automatically determining the appropriate SQL dialect from a DataSource.

/**
 * Utility to lookup well known SQL dialects from a DataSource
 * Used internally for auto-detection when spring.jooq.sql-dialect is not specified
 */
final class SqlDialectLookup {
    
    /**
     * Return the most suitable SQL dialect for the given DataSource
     * @param dataSource the source DataSource
     * @return the most suitable SQL dialect, or SQLDialect.DEFAULT if detection fails
     */
    static SQLDialect getDialect(DataSource dataSource);
}

Usage Examples:

Application Properties Configuration

# Specify SQL dialect explicitly (otherwise auto-detected)
spring.jooq.sql-dialect=MYSQL

# Specify external jOOQ configuration file
spring.jooq.config=classpath:jooq-config.xml
# YAML format
spring:
  jooq:
    sql-dialect: POSTGRESQL
    config: classpath:config/jooq-settings.xml

Custom Configuration via Customizer

@Component
public class MyJooqCustomizer implements DefaultConfigurationCustomizer {
    
    @Override
    public void customize(DefaultConfiguration configuration) {
        // Add custom converters
        configuration.set(new LocalDateTimeConverter());
        
        // Add custom execute listeners
        configuration.set(new DefaultExecuteListenerProvider(
            new MyCustomExecuteListener()
        ));
        
        // Customize settings programmatically
        Settings settings = new Settings();
        settings.withExecuteLogging(true);
        settings.withRenderSchema(false);
        configuration.set(settings);
    }
}

External jOOQ Configuration File

When spring.jooq.config is specified, you can provide an external XML configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-runtime-3.18.0.xsd">
    <settings>
        <executeLogging>true</executeLogging>
        <renderSchema>false</renderSchema>
        <renderNamedParamPrefix>$</renderNamedParamPrefix>
        <fetchWarnings>true</fetchWarnings>
    </settings>
</configuration>

SQL Dialect Auto-Detection

The SQL dialect is automatically detected based on your DataSource configuration:

// Auto-detection examples based on JDBC URL patterns:
// jdbc:mysql://... -> SQLDialect.MYSQL  
// jdbc:postgresql://... -> SQLDialect.POSTGRES
// jdbc:h2:... -> SQLDialect.H2
// jdbc:oracle:... -> SQLDialect.ORACLE
// etc.

@Service
public class DatabaseService {
    
    @Autowired
    private DSLContext dsl;
    
    public void demonstrateDialectSpecificFeatures() {
        // The DSLContext automatically uses the correct dialect
        // MySQL-specific syntax when using MySQL
        // PostgreSQL-specific syntax when using PostgreSQL
        // etc.
    }
}

Multiple Configuration Customizers

You can define multiple customizers with ordering:

@Component
@Order(1)
public class ConverterCustomizer implements DefaultConfigurationCustomizer {
    @Override
    public void customize(DefaultConfiguration configuration) {
        // Add data type converters
        configuration.set(new LocalDateConverter());
    }
}

@Component  
@Order(2)
public class ListenerCustomizer implements DefaultConfigurationCustomizer {
    @Override
    public void customize(DefaultConfiguration configuration) {
        // Add execute listeners (after converters)
        configuration.set(new DefaultExecuteListenerProvider(
            new AuditingExecuteListener()
        ));
    }
}

Configuration Properties Reference

spring.jooq.sql-dialect

  • Type: org.jooq.SQLDialect enum value
  • Default: Auto-detected from DataSource
  • Valid Values: H2, MYSQL, MARIADB, POSTGRES, ORACLE, SQLSERVER, SQLITE, DERBY, HSQLDB, etc.
  • Description: Explicitly specify the SQL dialect instead of auto-detection

spring.jooq.config

  • Type: Spring Resource (file path, classpath, URL)
  • Default: Not set
  • Description: Location of external jOOQ XML configuration file
  • Examples:
    • classpath:jooq-config.xml
    • file:/path/to/config.xml
    • config/jooq-settings.xml

Note: When using spring.jooq.config, JAXB must be available on the classpath for XML parsing. If JAXB is not available, a JaxbNotAvailableException will be thrown with helpful error information.

Install with Tessl CLI

npx tessl i tessl/maven-org-springframework-boot--spring-boot-starter-jooq

docs

auto-configuration.md

configuration.md

exception-handling.md

index.md

testing-integration.md

transaction-integration.md

tile.json