use of org.seasar.doma.jdbc.dialect.StandardDialect 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.StandardDialect in project doma by domaframework.
the class AbstractSqlFileRepositoryTest method testGetSqlFile_illegalPath.
@Test
public void testGetSqlFile_illegalPath(TestInfo testInfo) {
SqlFileRepository repository = new MySqlFileRepository();
Method method = testInfo.getTestMethod().get();
String path = method.getName();
Dialect dialect = new StandardDialect();
try {
repository.getSqlFile(method, path, dialect);
fail();
} catch (DomaIllegalArgumentException ignored) {
}
}
use of org.seasar.doma.jdbc.dialect.StandardDialect in project doma by domaframework.
the class AbstractSqlFileRepositoryTest method testGetSqlFile.
@Test
public void testGetSqlFile(TestInfo testInfo) {
SqlFileRepository repository = new MySqlFileRepository();
Method method = testInfo.getTestMethod().get();
String path = String.format("META-INF/%s.sql", getClass().getName().replace(".", "/"));
Dialect dialect = new StandardDialect();
SqlFile sqlFile = repository.getSqlFile(method, path, dialect);
assertEquals("select * from employee", sqlFile.getSql());
}
use of org.seasar.doma.jdbc.dialect.StandardDialect in project doma by domaframework.
the class JdbcExceptionTest method testSqlFileNotFound.
@Test
public void testSqlFileNotFound() {
GreedyCacheSqlFileRepository repository = new GreedyCacheSqlFileRepository();
try {
repository.getSqlFile(method, "META-INF/aaa/bbb.sql", new StandardDialect());
fail();
} catch (SqlFileNotFoundException e) {
System.out.println(e.getMessage());
assertEquals(Message.DOMA2011, e.getMessageResource());
}
}
use of org.seasar.doma.jdbc.dialect.StandardDialect in project doma by domaframework.
the class GreedyCacheSqlFileRepositoryTest method testGetSqlFile.
@Test
public void testGetSqlFile() {
StandardDialect dialect = new StandardDialect();
String path = "META-INF/" + getClass().getName().replace(".", "/") + ".sql";
GreedyCacheSqlFileRepository repository = new GreedyCacheSqlFileRepository();
SqlFile sqlFile = repository.getSqlFile(method, path, dialect);
assertNotNull(sqlFile);
SqlFile sqlFile2 = repository.getSqlFile(method, path, dialect);
assertSame(sqlFile, sqlFile2);
assertEquals(path, sqlFile.getPath());
}
Aggregations