001/* 002 * Copyright 2012-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.autoconfigure.jooq; 018 019import javax.sql.DataSource; 020 021import org.jooq.SQLDialect; 022 023import org.springframework.boot.context.properties.ConfigurationProperties; 024 025/** 026 * Configuration properties for the JOOQ database library. 027 * 028 * @author Andreas Ahlenstorf 029 * @author Michael Simons 030 * @since 1.3.0 031 */ 032@ConfigurationProperties(prefix = "spring.jooq") 033public class JooqProperties { 034 035 /** 036 * SQL dialect to use. Auto-detected by default. 037 */ 038 private SQLDialect sqlDialect; 039 040 public SQLDialect getSqlDialect() { 041 return this.sqlDialect; 042 } 043 044 public void setSqlDialect(SQLDialect sqlDialect) { 045 this.sqlDialect = sqlDialect; 046 } 047 048 /** 049 * Determine the {@link SQLDialect} to use based on this configuration and the primary 050 * {@link DataSource}. 051 * @param dataSource the data source 052 * @return the {@code SQLDialect} to use for that {@link DataSource} 053 */ 054 public SQLDialect determineSqlDialect(DataSource dataSource) { 055 if (this.sqlDialect != null) { 056 return this.sqlDialect; 057 } 058 return SqlDialectLookup.getDialect(dataSource); 059 } 060 061}