use of org.seasar.doma.jdbc.builder.SelectBuilder in project doma by domaframework.
the class SelectBuilderTest method testGetMapSingleResult_null.
@Test
public void testGetMapSingleResult_null(Config config) throws Exception {
SelectBuilder builder = SelectBuilder.newInstance(config);
builder.sql("select EMPLOYEE_ID, EMPLOYEE_NAME, HIREDATE from EMPLOYEE");
builder.sql("where");
builder.sql("EMPLOYEE_ID = ").param(int.class, 99);
Map<String, Object> employee = builder.getMapSingleResult(MapKeyNamingType.CAMEL_CASE);
assertNull(employee);
}
use of org.seasar.doma.jdbc.builder.SelectBuilder in project doma by domaframework.
the class SelectBuilderTest method testGetOptionalScalarSingleResult.
@Test
public void testGetOptionalScalarSingleResult(Config config) throws Exception {
SelectBuilder builder = SelectBuilder.newInstance(config);
builder.sql("select EMPLOYEE_NAME from EMPLOYEE");
builder.sql("where");
builder.sql("EMPLOYEE_ID = ").param(int.class, 1);
Optional<String> name = builder.getOptionalScalarSingleResult(String.class);
assertEquals("SMITH", name.get());
}
use of org.seasar.doma.jdbc.builder.SelectBuilder in project doma by domaframework.
the class SelectBuilderTest method testStreamMap.
@Test
public void testStreamMap(Config config) throws Exception {
SelectBuilder builder = SelectBuilder.newInstance(config);
builder.sql("select EMPLOYEE_ID, EMPLOYEE_NAME, HIREDATE from EMPLOYEE");
Optional<Map<String, Object>> result = builder.streamMap(MapKeyNamingType.CAMEL_CASE, stream -> stream.findFirst());
assertEquals("SMITH", result.get().get("employeeName"));
}
use of org.seasar.doma.jdbc.builder.SelectBuilder in project doma by domaframework.
the class SelectBuilderTest method testGetEntityResultList.
@Test
public void testGetEntityResultList(Config config) throws Exception {
SelectBuilder builder = SelectBuilder.newInstance(config);
builder.sql("select EMPLOYEE_ID, EMPLOYEE_NAME, HIREDATE from EMPLOYEE");
List<Employee> employees = builder.getEntityResultList(Employee.class);
assertEquals(14, employees.size());
assertEquals("SMITH", employees.get(0).getEmployeeName());
}
use of org.seasar.doma.jdbc.builder.SelectBuilder in project doma by domaframework.
the class SelectBuilderTest method testStreamScalar.
@Test
public void testStreamScalar(Config config) throws Exception {
SelectBuilder builder = SelectBuilder.newInstance(config);
builder.sql("select EMPLOYEE_NAME from EMPLOYEE");
builder.sql("where");
builder.sql("EMPLOYEE_ID = ").param(int.class, 1);
Optional<String> name = builder.streamScalar(String.class, stream -> stream.findFirst());
assertEquals("SMITH", name.get());
}