use of org.seasar.doma.jdbc.dialect.Dialect in project doma-spring-boot by domaframework.
the class DomaAutoConfigurationTest method testDialectByDataSourceUrl.
@Test
public void testDialectByDataSourceUrl() {
MutablePropertySources sources = context.getEnvironment().getPropertySources();
sources.addFirst(new MapPropertySource("test", Collections.singletonMap("spring.datasource.url", "jdbc:h2:mem:example")));
this.context.register(DomaAutoConfiguration.class, DataSourceAutoConfiguration.class);
this.context.refresh();
Dialect dialect = this.context.getBean(Dialect.class);
assertThat(dialect, is(instanceOf(H2Dialect.class)));
}
use of org.seasar.doma.jdbc.dialect.Dialect in project doma-spring-boot by domaframework.
the class DomaAutoConfigurationTest method testDialectByDomaPropertiesIgnoreDataSourceUrl.
@Test
public void testDialectByDomaPropertiesIgnoreDataSourceUrl() {
MutablePropertySources sources = context.getEnvironment().getPropertySources();
Map<String, Object> source = new HashMap<>();
source.put("spring.datasource.url", "jdbc:h2:mem:example");
source.put("doma.dialect", "POSTGRES");
sources.addFirst(new MapPropertySource("test", source));
this.context.register(DomaAutoConfiguration.class, DataSourceAutoConfiguration.class);
this.context.refresh();
Dialect dialect = this.context.getBean(Dialect.class);
assertThat(dialect, is(instanceOf(PostgresDialect.class)));
}
use of org.seasar.doma.jdbc.dialect.Dialect 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.Dialect 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.Dialect in project doma by domaframework.
the class ModifyCommand method prepareStatement.
protected PreparedStatement prepareStatement(Connection connection) {
if (query.isAutoGeneratedKeysSupported()) {
Config config = query.getConfig();
Dialect dialect = config.getDialect();
switch(dialect.getAutoGeneratedKeysType()) {
case FIRST_COLUMN:
return JdbcUtil.prepareStatementForAutoGeneratedKeysOfFirstColumn(connection, sql);
case DEFAULT:
return JdbcUtil.prepareStatementForAutoGeneratedKeys(connection, sql);
}
}
return JdbcUtil.prepareStatement(connection, sql);
}
Aggregations