Search in sources :

Example 1 with Db2Dialect

use of org.seasar.doma.jdbc.dialect.Db2Dialect in project doma-spring-boot by domaframework.

the class DomaAutoConfiguration method dialect.

@Bean
@ConditionalOnMissingBean
public Dialect dialect(Environment environment) {
    DialectType dialectType = domaProperties.getDialect();
    if (dialectType != null) {
        return dialectType.create();
    }
    String url = environment.getProperty("spring.datasource.url");
    if (url != null) {
        DatabaseDriver databaseDriver = DatabaseDriver.fromJdbcUrl(url);
        switch(databaseDriver) {
            case DB2:
                return new Db2Dialect();
            case H2:
                return new H2Dialect();
            case HSQLDB:
                return new HsqldbDialect();
            case SQLSERVER:
            case JTDS:
                return new MssqlDialect();
            case MYSQL:
                return new MysqlDialect();
            case ORACLE:
                return new OracleDialect();
            case POSTGRESQL:
                return new PostgresDialect();
            case SQLITE:
                return new SqliteDialect();
            default:
                break;
        }
    }
    if (logger.isWarnEnabled()) {
        logger.warn("StandardDialect was selected because no explicit configuration and it is not possible to guess from 'spring.datasource.url property'");
    }
    return new StandardDialect();
}
Also used : HsqldbDialect(org.seasar.doma.jdbc.dialect.HsqldbDialect) MysqlDialect(org.seasar.doma.jdbc.dialect.MysqlDialect) H2Dialect(org.seasar.doma.jdbc.dialect.H2Dialect) MssqlDialect(org.seasar.doma.jdbc.dialect.MssqlDialect) OracleDialect(org.seasar.doma.jdbc.dialect.OracleDialect) DialectType(org.seasar.doma.boot.autoconfigure.DomaProperties.DialectType) DatabaseDriver(org.springframework.boot.jdbc.DatabaseDriver) SqliteDialect(org.seasar.doma.jdbc.dialect.SqliteDialect) StandardDialect(org.seasar.doma.jdbc.dialect.StandardDialect) PostgresDialect(org.seasar.doma.jdbc.dialect.PostgresDialect) Db2Dialect(org.seasar.doma.jdbc.dialect.Db2Dialect) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with Db2Dialect

use of org.seasar.doma.jdbc.dialect.Db2Dialect in project doma by domaframework.

the class NativeSqlSelectTest method forUpdate_db2.

@Test
void forUpdate_db2() {
    NativeSql nativeSql = new NativeSql(new MockConfig() {

        @Override
        public Dialect getDialect() {
            return new Db2Dialect();
        }
    });
    Emp_ e = new Emp_();
    Buildable<?> stmt = nativeSql.from(e).where(c -> c.eq(e.id, 1)).forUpdate().select(e.id);
    Sql<?> sql = stmt.asSql();
    assertEquals("select t0_.ID from EMP t0_ where t0_.ID = 1 for update with rs", sql.getFormattedSql());
}
Also used : Emp_(org.seasar.doma.jdbc.criteria.entity.Emp_) NoIdEmp_(org.seasar.doma.jdbc.criteria.entity.NoIdEmp_) Dialect(org.seasar.doma.jdbc.dialect.Dialect) Db2Dialect(org.seasar.doma.jdbc.dialect.Db2Dialect) OracleDialect(org.seasar.doma.jdbc.dialect.OracleDialect) MssqlDialect(org.seasar.doma.jdbc.dialect.MssqlDialect) Mssql2008Dialect(org.seasar.doma.jdbc.dialect.Mssql2008Dialect) PostgresDialect(org.seasar.doma.jdbc.dialect.PostgresDialect) MockConfig(org.seasar.doma.internal.jdbc.mock.MockConfig) Db2Dialect(org.seasar.doma.jdbc.dialect.Db2Dialect) Test(org.junit.jupiter.api.Test)

Aggregations

Db2Dialect (org.seasar.doma.jdbc.dialect.Db2Dialect)2 MssqlDialect (org.seasar.doma.jdbc.dialect.MssqlDialect)2 OracleDialect (org.seasar.doma.jdbc.dialect.OracleDialect)2 PostgresDialect (org.seasar.doma.jdbc.dialect.PostgresDialect)2 Test (org.junit.jupiter.api.Test)1 DialectType (org.seasar.doma.boot.autoconfigure.DomaProperties.DialectType)1 MockConfig (org.seasar.doma.internal.jdbc.mock.MockConfig)1 Emp_ (org.seasar.doma.jdbc.criteria.entity.Emp_)1 NoIdEmp_ (org.seasar.doma.jdbc.criteria.entity.NoIdEmp_)1 Dialect (org.seasar.doma.jdbc.dialect.Dialect)1 H2Dialect (org.seasar.doma.jdbc.dialect.H2Dialect)1 HsqldbDialect (org.seasar.doma.jdbc.dialect.HsqldbDialect)1 Mssql2008Dialect (org.seasar.doma.jdbc.dialect.Mssql2008Dialect)1 MysqlDialect (org.seasar.doma.jdbc.dialect.MysqlDialect)1 SqliteDialect (org.seasar.doma.jdbc.dialect.SqliteDialect)1 StandardDialect (org.seasar.doma.jdbc.dialect.StandardDialect)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 DatabaseDriver (org.springframework.boot.jdbc.DatabaseDriver)1 Bean (org.springframework.context.annotation.Bean)1