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 Dependency | Reason |
|---|---|
spring-boot-starter-data-jpa | Includes JPA/Hibernate |
hibernate-core | ORM framework |
spring-data-jpa | JPA abstraction |
6.1.2. Rationale for Choosing jOOQ over JPA
| Aspect | jOOQ | JPA/Hibernate |
|---|---|---|
| SQL Control | Developers write SQL directly | ORM generates SQL automatically |
| Performance Predictability | Executed SQL is exactly predictable | N+1 problems, lazy loading make prediction difficult |
| Type Safety | SQL errors detected at compile time | Errors occur at runtime |
| Complex Queries | Native SQL-level expressiveness | JPQL limitations, native queries required |
| Schema Synchronization | Always up-to-date via Flyway + codegen | Risk 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: postgres6.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);
};
}
}| Setting | Value | Description |
|---|---|---|
renderNameCase | LOWER | Use lowercase for SQL rendering |
renderQuotedNames | NEVER | Do not use identifier quoting |
executeLogging | true | Enable executed SQL logging |