Search in sources :

Example 1 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class AutoDeleteTest method testIgnoreVersion.

@Test
public void testIgnoreVersion(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    Employee employee = new Employee();
    employee.setEmployeeId(1);
    employee.setVersion(99);
    int result = dao.delete_ignoreVersion(employee);
    assertEquals(1, result);
    employee = dao.selectById(Integer.valueOf(1));
    assertNull(employee);
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) CompKeyEmployeeDao(org.seasar.doma.it.dao.CompKeyEmployeeDao) CompKeyEmployee(org.seasar.doma.it.entity.CompKeyEmployee) Employee(org.seasar.doma.it.entity.Employee) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) CompKeyEmployeeDaoImpl(org.seasar.doma.it.dao.CompKeyEmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Example 2 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class AutoDeleteTest method testOptimisticLockException.

@Test
public void testOptimisticLockException(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    Employee employee1 = dao.selectById(Integer.valueOf(1));
    employee1.setEmployeeName("hoge");
    Employee employee2 = dao.selectById(Integer.valueOf(1));
    employee2.setEmployeeName("foo");
    dao.delete(employee1);
    try {
        dao.delete(employee2);
        fail();
    } catch (OptimisticLockException expected) {
    }
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) CompKeyEmployeeDao(org.seasar.doma.it.dao.CompKeyEmployeeDao) CompKeyEmployee(org.seasar.doma.it.entity.CompKeyEmployee) Employee(org.seasar.doma.it.entity.Employee) OptimisticLockException(org.seasar.doma.jdbc.OptimisticLockException) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) CompKeyEmployeeDaoImpl(org.seasar.doma.it.dao.CompKeyEmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Example 3 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class PrimitiveTypeTest method map_null_to_reference_type.

@Test
void map_null_to_reference_type(Config config) {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    Employee e = dao.selectById(9);
    Integer managerId = e.getManagerId();
    assertNull(managerId);
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) PhantomEmployeeDao(org.seasar.doma.it.dao.PhantomEmployeeDao) Employee(org.seasar.doma.it.entity.Employee) PhantomEmployee(org.seasar.doma.it.entity.PhantomEmployee) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) PhantomEmployeeDaoImpl(org.seasar.doma.it.dao.PhantomEmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Example 4 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class SqlFileSelectCollectorTest method testCollectAll2.

@Test
public void testCollectAll2(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    Map<Identity<Department>, List<Employee>> group = dao.collectAll(Collectors.groupingBy(Employee::getDepartmentId));
    System.out.println(group);
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) List(java.util.List) Identity(org.seasar.doma.it.domain.Identity) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Example 5 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class SqlFileSelectCountTest method test.

@Test
public void test(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    SelectOptions options = SelectOptions.get().count();
    List<Employee> employees = dao.selectAll(options);
    assertEquals(14, employees.size());
    assertEquals(14, options.getCount());
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) Employee(org.seasar.doma.it.entity.Employee) SelectOptions(org.seasar.doma.jdbc.SelectOptions) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)54 EmployeeDao (org.seasar.doma.it.dao.EmployeeDao)54 EmployeeDaoImpl (org.seasar.doma.it.dao.EmployeeDaoImpl)54 Employee (org.seasar.doma.it.entity.Employee)43 Run (org.seasar.doma.it.Run)8 CompKeyEmployeeDao (org.seasar.doma.it.dao.CompKeyEmployeeDao)8 CompKeyEmployeeDaoImpl (org.seasar.doma.it.dao.CompKeyEmployeeDaoImpl)8 CompKeyEmployee (org.seasar.doma.it.entity.CompKeyEmployee)8 SelectOptions (org.seasar.doma.jdbc.SelectOptions)8 BigDecimal (java.math.BigDecimal)6 Objects (java.util.Objects)4 Stream (java.util.stream.Stream)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)4 IntegrationTestEnvironment (org.seasar.doma.it.IntegrationTestEnvironment)4 Config (org.seasar.doma.jdbc.Config)4 HiredateImpl (org.seasar.doma.it.domain.HiredateImpl)2 OptimisticLockException (org.seasar.doma.jdbc.OptimisticLockException)2 List (java.util.List)1