use of org.seasar.doma.it.entity.Employee in project doma by domaframework.
the class CriteriaDao method selectAll.
default List<Employee> selectAll() {
Employee_ e = new Employee_();
Department_ d = new Department_();
Entityql entityql = new Entityql(Config.get(this));
return entityql.from(e).innerJoin(d, on -> on.eq(e.departmentId, d.departmentId)).associate(e, d, (employee, department) -> {
employee.setDepartment(department);
department.getEmployeeList().add(employee);
}).fetch();
}
use of org.seasar.doma.it.entity.Employee in project doma by domaframework.
the class SqlFileSelectTest method testSuffixSearch.
@Test
public void testSuffixSearch(Config config) throws Exception {
EmployeeDao dao = new EmployeeDaoImpl(config);
List<Employee> employees = dao.selectByNameSuffix("S");
assertEquals(3, employees.size());
}
use of org.seasar.doma.it.entity.Employee in project doma by domaframework.
the class SqlFileSelectPagingTest method testLimitOffset_limitIsZero.
@Test
public void testLimitOffset_limitIsZero(Config config) throws Exception {
EmployeeDao dao = new EmployeeDaoImpl(config);
List<Employee> employees = dao.selectAll(SelectOptions.get().limit(0).offset(10));
assertEquals(4, employees.size());
assertEquals(Integer.valueOf(11), employees.get(0).getEmployeeId());
assertEquals(Integer.valueOf(12), employees.get(1).getEmployeeId());
assertEquals(Integer.valueOf(13), employees.get(2).getEmployeeId());
assertEquals(Integer.valueOf(14), employees.get(3).getEmployeeId());
}
use of org.seasar.doma.it.entity.Employee in project doma by domaframework.
the class SqlFileSelectPagingTest method testLimitOffset_offsetIsZero.
@Test
public void testLimitOffset_offsetIsZero(Config config) throws Exception {
EmployeeDao dao = new EmployeeDaoImpl(config);
List<Employee> employees = dao.selectAll(SelectOptions.get().limit(5).offset(0));
assertEquals(5, employees.size());
assertEquals(Integer.valueOf(1), employees.get(0).getEmployeeId());
assertEquals(Integer.valueOf(2), employees.get(1).getEmployeeId());
assertEquals(Integer.valueOf(3), employees.get(2).getEmployeeId());
assertEquals(Integer.valueOf(4), employees.get(3).getEmployeeId());
assertEquals(Integer.valueOf(5), employees.get(4).getEmployeeId());
}
use of org.seasar.doma.it.entity.Employee in project doma by domaframework.
the class SqlFileSelectStreamTest method testStreamAll_resultStream.
@Test
public void testStreamAll_resultStream(Config config) throws Exception {
EmployeeDao dao = new EmployeeDaoImpl(config);
Long count = null;
try (Stream<Employee> stream = dao.streamAll()) {
count = stream.filter(e -> e.getEmployeeName() != null).filter(e -> e.getEmployeeName().startsWith("S")).count();
}
assertEquals(Long.valueOf(2), count);
}
Aggregations