From 5dbe6232b825e41008425aad5cd5567e1fcf881b Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 13 Jul 2015 12:30:17 -0700 Subject: [PATCH] Use jOOQ enum for sqlDialect Switch JooqProperties.sqlDialect from a String to the actual enum to allow IDE hints and case insensitive binding. Fixes gh-3468 --- .../boot/autoconfigure/jooq/JooqAutoConfiguration.java | 6 ++---- .../boot/autoconfigure/jooq/JooqProperties.java | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java index c4e747e3e8..09406a1480 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java @@ -23,7 +23,6 @@ import org.jooq.DSLContext; import org.jooq.ExecuteListenerProvider; import org.jooq.RecordListenerProvider; import org.jooq.RecordMapperProvider; -import org.jooq.SQLDialect; import org.jooq.TransactionProvider; import org.jooq.VisitListenerProvider; import org.jooq.conf.Settings; @@ -43,7 +42,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.util.StringUtils; /** * {@link EnableAutoConfiguration Auto-configuration} for JOOQ. @@ -113,8 +111,8 @@ public class JooqAutoConfiguration { @ConditionalOnMissingBean(org.jooq.Configuration.class) public DefaultConfiguration jooqConfiguration() { DefaultConfiguration configuration = new DefaultConfiguration(); - if (!StringUtils.isEmpty(this.properties.getSqlDialect())) { - configuration.set(SQLDialect.valueOf(this.properties.getSqlDialect())); + if (this.properties.getSqlDialect() != null) { + configuration.set(this.properties.getSqlDialect()); } configuration.set(this.connectionProvider); if (this.transactionProvider != null) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqProperties.java index 46195fef6e..3522bea07c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqProperties.java @@ -16,6 +16,7 @@ package org.springframework.boot.autoconfigure.jooq; +import org.jooq.SQLDialect; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -31,13 +32,13 @@ public class JooqProperties { * SQLDialect JOOQ used when communicating with the configured datasource, for * instance "POSTGRES". */ - private String sqlDialect; + private SQLDialect sqlDialect; - public String getSqlDialect() { + public SQLDialect getSqlDialect() { return this.sqlDialect; } - public void setSqlDialect(String sqlDialect) { + public void setSqlDialect(SQLDialect sqlDialect) { this.sqlDialect = sqlDialect; }