Search in sources :

Example 1 with OracleDialect

use of org.seasar.doma.jdbc.dialect.OracleDialect 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 OracleDialect

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

the class NativeSqlSelectTest method forUpdate_oracle_nowait.

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

        @Override
        public Dialect getDialect() {
            return new OracleDialect();
        }
    });
    Emp_ e = new Emp_();
    Buildable<?> stmt = nativeSql.from(e).forUpdate(ForUpdateOption.noWait()).select(e.id);
    Sql<?> sql = stmt.asSql();
    assertEquals("select t0_.ID from EMP t0_ for update nowait", sql.getFormattedSql());
}
Also used : OracleDialect(org.seasar.doma.jdbc.dialect.OracleDialect) 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) Test(org.junit.jupiter.api.Test)

Example 3 with OracleDialect

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

the class NativeSqlSelectTest method forUpdate_oracle_wait_withColumn.

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

        @Override
        public Dialect getDialect() {
            return new OracleDialect();
        }
    });
    Emp_ e = new Emp_();
    Dept_ d = new Dept_();
    Buildable<?> stmt = nativeSql.from(e).innerJoin(d, on -> on.eq(e.id, d.id)).forUpdate(ForUpdateOption.wait(5, e.id, d.id)).select(e.id);
    Sql<?> sql = stmt.asSql();
    assertEquals("select t0_.ID from EMP t0_ inner join CATA.DEPT t1_ on (t0_.ID = t1_.ID) for update of t0_.ID, t1_.ID wait 5", sql.getFormattedSql());
}
Also used : OracleDialect(org.seasar.doma.jdbc.dialect.OracleDialect) Emp_(org.seasar.doma.jdbc.criteria.entity.Emp_) NoIdEmp_(org.seasar.doma.jdbc.criteria.entity.NoIdEmp_) Dept_(org.seasar.doma.jdbc.criteria.entity.Dept_) 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) Test(org.junit.jupiter.api.Test)

Example 4 with OracleDialect

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

the class NativeSqlSelectTest method forUpdate_oracle_nowait_withColumn.

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

        @Override
        public Dialect getDialect() {
            return new OracleDialect();
        }
    });
    Emp_ e = new Emp_();
    Dept_ d = new Dept_();
    Buildable<?> stmt = nativeSql.from(e).innerJoin(d, on -> on.eq(e.id, d.id)).forUpdate(ForUpdateOption.noWait(e.id, d.id)).select(e.id);
    Sql<?> sql = stmt.asSql();
    assertEquals("select t0_.ID from EMP t0_ inner join CATA.DEPT t1_ on (t0_.ID = t1_.ID) for update of t0_.ID, t1_.ID nowait", sql.getFormattedSql());
}
Also used : OracleDialect(org.seasar.doma.jdbc.dialect.OracleDialect) Emp_(org.seasar.doma.jdbc.criteria.entity.Emp_) NoIdEmp_(org.seasar.doma.jdbc.criteria.entity.NoIdEmp_) Dept_(org.seasar.doma.jdbc.criteria.entity.Dept_) 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) Test(org.junit.jupiter.api.Test)

Example 5 with OracleDialect

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

the class GreedyCacheSqlFileRepositoryTest method testGetSqlFile_oracle.

@Test
public void testGetSqlFile_oracle() {
    OracleDialect dialect = new OracleDialect();
    String path = "META-INF/" + getClass().getName().replace(".", "/") + ".sql";
    GreedyCacheSqlFileRepository repository = new GreedyCacheSqlFileRepository();
    SqlFile sqlFile = repository.getSqlFile(method, path, dialect);
    assertEquals("META-INF/" + getClass().getName().replace(".", "/") + "-oracle.sql", sqlFile.getPath());
}
Also used : OracleDialect(org.seasar.doma.jdbc.dialect.OracleDialect) Test(org.junit.jupiter.api.Test)

Aggregations

OracleDialect (org.seasar.doma.jdbc.dialect.OracleDialect)5 Test (org.junit.jupiter.api.Test)4 Db2Dialect (org.seasar.doma.jdbc.dialect.Db2Dialect)4 MssqlDialect (org.seasar.doma.jdbc.dialect.MssqlDialect)4 PostgresDialect (org.seasar.doma.jdbc.dialect.PostgresDialect)4 MockConfig (org.seasar.doma.internal.jdbc.mock.MockConfig)3 Emp_ (org.seasar.doma.jdbc.criteria.entity.Emp_)3 NoIdEmp_ (org.seasar.doma.jdbc.criteria.entity.NoIdEmp_)3 Dialect (org.seasar.doma.jdbc.dialect.Dialect)3 Mssql2008Dialect (org.seasar.doma.jdbc.dialect.Mssql2008Dialect)3 Dept_ (org.seasar.doma.jdbc.criteria.entity.Dept_)2 DialectType (org.seasar.doma.boot.autoconfigure.DomaProperties.DialectType)1 H2Dialect (org.seasar.doma.jdbc.dialect.H2Dialect)1 HsqldbDialect (org.seasar.doma.jdbc.dialect.HsqldbDialect)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