use of org.seasar.doma.jdbc.dialect.MysqlDialect 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.MysqlDialect in project doma by domaframework.
the class AutoInsertQueryTest method testPrepare_MySql_autoIncrement.
@Test
public void testPrepare_MySql_autoIncrement() {
runtimeConfig.setDialect(new MysqlDialect());
AutoIncrement autoIncrement = new AutoIncrement();
AutoInsertQuery<AutoIncrement> query = new AutoInsertQuery<>(_AutoIncrement.getSingletonInternal());
query.setMethod(method);
query.setConfig(runtimeConfig);
query.setEntity(autoIncrement);
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
assertEquals("insert into AutoIncrement () values ()", query.getSql().getRawSql());
}
use of org.seasar.doma.jdbc.dialect.MysqlDialect in project doma by domaframework.
the class NativeSqlDeleteTest method aliasInDeleteClause.
@Test
void aliasInDeleteClause() {
MockConfig config = new MockConfig();
config.dialect = new MysqlDialect();
NativeSql nativeSql = new NativeSql(config);
Emp_ e = new Emp_();
Statement<Integer> stmt = nativeSql.delete(e);
Sql<?> sql = stmt.asSql();
assertEquals("delete t0_ from EMP t0_", sql.getFormattedSql());
}
Aggregations