Skip to content

6.1. jOOQ Overview and Configuration ​

6.1. jOOQ Overview ​

6.1.1. JPA Usage Prohibited ​

JPA (Hibernate) is prohibited in TQS certified projects. The following dependencies must not be included.

Prohibited DependencyReason
spring-boot-starter-data-jpaIncludes JPA/Hibernate
hibernate-coreORM framework
spring-data-jpaJPA abstraction

6.1.2. Rationale for Choosing jOOQ over JPA ​

AspectjOOQJPA/Hibernate
SQL ControlDevelopers write SQL directlyORM generates SQL automatically
Performance PredictabilityExecuted SQL is exactly predictableN+1 problems, lazy loading make prediction difficult
Type SafetySQL errors detected at compile timeErrors occur at runtime
Complex QueriesNative SQL-level expressivenessJPQL limitations, native queries required
Schema SynchronizationAlways up-to-date via Flyway + codegenRisk of entity mapping mismatch

6.1.3. Standard Dependency ​

xml
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-jooq</artifactId>
</dependency>

spring-boot-starter-jooq includes the following:

  • jOOQ core library
  • Spring Transaction integration
  • DSLContext auto-configuration

6.2. DSLContext Configuration ​

6.2.1. Auto-configuration ​

Through Spring Boot's auto-configuration, DSLContext is registered as a Bean. By adding the datasource and jOOQ settings to application.yml, it can be used without any additional Java configuration.

yaml
spring:
  jooq:
    sql-dialect: postgres

6.2.2. Custom Configuration (When Needed) ​

A configuration class should only be written when customization of jOOQ's detailed behavior is required.

java
@Configuration
public class JooqConfig {

  @Bean
  public DefaultConfigurationCustomizer jooqConfigCustomizer() {
    return configuration -> {
      configuration.settings()
          .withRenderNameCase(RenderNameCase.LOWER)
          .withRenderQuotedNames(RenderQuotedNames.NEVER)
          .withExecuteLogging(true);
    };
  }
}
SettingValueDescription
renderNameCaseLOWERUse lowercase for SQL rendering
renderQuotedNamesNEVERDo not use identifier quoting
executeLoggingtrueEnable executed SQL logging

TIENIPIA QUALIFIED STANDARD