use of org.seasar.doma.jdbc.dialect.MssqlDialect 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();
}
use of org.seasar.doma.jdbc.dialect.MssqlDialect in project doma by domaframework.
the class NativeSqlSelectTest method forUpdate_mssql_nowait.
@Test
void forUpdate_mssql_nowait() {
NativeSql nativeSql = new NativeSql(new MockConfig() {
@Override
public Dialect getDialect() {
return new MssqlDialect();
}
});
Emp_ e = new Emp_();
Buildable<?> stmt = nativeSql.from(e).where(c -> c.eq(e.id, 1)).forUpdate(ForUpdateOption.noWait()).select(e.id);
Sql<?> sql = stmt.asSql();
assertEquals("select t0_.ID from EMP t0_ with (updlock, rowlock, nowait) where t0_.ID = 1", sql.getFormattedSql());
}
use of org.seasar.doma.jdbc.dialect.MssqlDialect in project doma by domaframework.
the class NativeSqlUpdateTest method aliasInUpdateClause.
@Test
void aliasInUpdateClause() {
MockConfig config = new MockConfig();
config.dialect = new MssqlDialect();
NativeSql nativeSql = new NativeSql(config);
Emp_ e = new Emp_();
Statement<Integer> stmt = nativeSql.update(e).set(c -> {
c.value(e.name, "bbb");
c.value(e.salary, new BigDecimal("1000"));
}).where(c -> c.eq(e.id, 1));
Sql<?> sql = stmt.asSql();
assertEquals("update t0_ set NAME = 'bbb', SALARY = 1000 from EMP t0_ where t0_.ID = 1", sql.getFormattedSql());
}
use of org.seasar.doma.jdbc.dialect.MssqlDialect in project doma by domaframework.
the class NativeSqlSelectTest method forUpdate_mssql.
@Test
void forUpdate_mssql() {
NativeSql nativeSql = new NativeSql(new MockConfig() {
@Override
public Dialect getDialect() {
return new MssqlDialect();
}
});
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_ with (updlock, rowlock) where t0_.ID = 1", sql.getFormattedSql());
}
Aggregations