Search in sources :

Example 21 with DepartmentDaoImpl

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

the class AutoProcedureTest method testResultSetAndUpdate2.

@Test
public void testResultSetAndUpdate2(Config config) throws Exception {
    ProcedureDao dao = new ProcedureDaoImpl(config);
    List<Employee> employees = new ArrayList<>();
    dao.proc_resultset_update2(employees, 1);
    assertEquals(13, employees.size());
    DepartmentDao departmentDao = new DepartmentDaoImpl(config);
    Department department = departmentDao.selectById(1);
    assertEquals("HOGE", department.getDepartmentName());
}
Also used : DepartmentDaoImpl(org.seasar.doma.it.dao.DepartmentDaoImpl) Department(org.seasar.doma.it.entity.Department) ProcedureDao(org.seasar.doma.it.dao.ProcedureDao) Employee(org.seasar.doma.it.entity.Employee) ProcedureDaoImpl(org.seasar.doma.it.dao.ProcedureDaoImpl) ArrayList(java.util.ArrayList) DepartmentDao(org.seasar.doma.it.dao.DepartmentDao) Test(org.junit.jupiter.api.Test)

Example 22 with DepartmentDaoImpl

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

the class AutoUpdateTest method test.

@Test
public void test(Config config) throws Exception {
    DepartmentDao dao = new DepartmentDaoImpl(config);
    Department department = dao.selectById(1);
    department.setDepartmentNo(1);
    department.setDepartmentName("hoge");
    int result = dao.update(department);
    assertEquals(1, result);
    assertEquals(Integer.valueOf(2), department.getVersion());
    department = dao.selectById(1);
    assertEquals(Integer.valueOf(1), department.getDepartmentId().getValue());
    assertEquals(Integer.valueOf(1), department.getDepartmentNo());
    assertEquals("hoge", department.getDepartmentName());
    assertEquals("NEW YORK", department.getLocation().getValue());
    assertEquals(Integer.valueOf(2), department.getVersion());
}
Also used : DepartmentDaoImpl(org.seasar.doma.it.dao.DepartmentDaoImpl) CompKeyDepartmentDaoImpl(org.seasar.doma.it.dao.CompKeyDepartmentDaoImpl) Department(org.seasar.doma.it.entity.Department) CompKeyDepartment(org.seasar.doma.it.entity.CompKeyDepartment) DepartmentDao(org.seasar.doma.it.dao.DepartmentDao) CompKeyDepartmentDao(org.seasar.doma.it.dao.CompKeyDepartmentDao) Test(org.junit.jupiter.api.Test)

Example 23 with DepartmentDaoImpl

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

the class AutoUpdateTest method testSuppressOptimisticLockException.

@Test
public void testSuppressOptimisticLockException(Config config) throws Exception {
    DepartmentDao dao = new DepartmentDaoImpl(config);
    Department department1 = dao.selectById(1);
    department1.setDepartmentName("hoge");
    Department department2 = dao.selectById(1);
    department2.setDepartmentName("foo");
    dao.update(department1);
    int rows = dao.update_suppressOptimisticLockException(department2);
    assertEquals(0, rows);
}
Also used : DepartmentDaoImpl(org.seasar.doma.it.dao.DepartmentDaoImpl) CompKeyDepartmentDaoImpl(org.seasar.doma.it.dao.CompKeyDepartmentDaoImpl) Department(org.seasar.doma.it.entity.Department) CompKeyDepartment(org.seasar.doma.it.entity.CompKeyDepartment) DepartmentDao(org.seasar.doma.it.dao.DepartmentDao) CompKeyDepartmentDao(org.seasar.doma.it.dao.CompKeyDepartmentDao) Test(org.junit.jupiter.api.Test)

Example 24 with DepartmentDaoImpl

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

the class AutoUpdateTest method testOptimisticLockException.

@Test
public void testOptimisticLockException(Config config) throws Exception {
    DepartmentDao dao = new DepartmentDaoImpl(config);
    Department department1 = dao.selectById(1);
    department1.setDepartmentName("hoge");
    Department department2 = dao.selectById(1);
    department2.setDepartmentName("foo");
    dao.update(department1);
    try {
        dao.update(department2);
        fail();
    } catch (OptimisticLockException expected) {
    }
}
Also used : DepartmentDaoImpl(org.seasar.doma.it.dao.DepartmentDaoImpl) CompKeyDepartmentDaoImpl(org.seasar.doma.it.dao.CompKeyDepartmentDaoImpl) Department(org.seasar.doma.it.entity.Department) CompKeyDepartment(org.seasar.doma.it.entity.CompKeyDepartment) OptimisticLockException(org.seasar.doma.jdbc.OptimisticLockException) DepartmentDao(org.seasar.doma.it.dao.DepartmentDao) CompKeyDepartmentDao(org.seasar.doma.it.dao.CompKeyDepartmentDao) Test(org.junit.jupiter.api.Test)

Example 25 with DepartmentDaoImpl

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

the class AutoUpdateTest method testExcludeNull.

@Test
public void testExcludeNull(Config config) throws Exception {
    DepartmentDao dao = new DepartmentDaoImpl(config);
    Department department = dao.selectById(1);
    department.setDepartmentNo(1);
    department.setDepartmentName(null);
    int result = dao.update_excludeNull(department);
    assertEquals(1, result);
    department = dao.selectById(1);
    assertEquals(Integer.valueOf(1), department.getDepartmentId().getValue());
    assertEquals(Integer.valueOf(1), department.getDepartmentNo());
    assertEquals("ACCOUNTING", department.getDepartmentName());
    assertEquals("NEW YORK", department.getLocation().getValue());
    assertEquals(Integer.valueOf(2), department.getVersion());
}
Also used : DepartmentDaoImpl(org.seasar.doma.it.dao.DepartmentDaoImpl) CompKeyDepartmentDaoImpl(org.seasar.doma.it.dao.CompKeyDepartmentDaoImpl) Department(org.seasar.doma.it.entity.Department) CompKeyDepartment(org.seasar.doma.it.entity.CompKeyDepartment) DepartmentDao(org.seasar.doma.it.dao.DepartmentDao) CompKeyDepartmentDao(org.seasar.doma.it.dao.CompKeyDepartmentDao) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)31 DepartmentDao (org.seasar.doma.it.dao.DepartmentDao)31 DepartmentDaoImpl (org.seasar.doma.it.dao.DepartmentDaoImpl)31 Department (org.seasar.doma.it.entity.Department)31 CompKeyDepartmentDao (org.seasar.doma.it.dao.CompKeyDepartmentDao)17 CompKeyDepartmentDaoImpl (org.seasar.doma.it.dao.CompKeyDepartmentDaoImpl)17 CompKeyDepartment (org.seasar.doma.it.entity.CompKeyDepartment)17 Employee (org.seasar.doma.it.entity.Employee)4 OptimisticLockException (org.seasar.doma.jdbc.OptimisticLockException)3 ArrayList (java.util.ArrayList)2 Run (org.seasar.doma.it.Run)2 FunctionDao (org.seasar.doma.it.dao.FunctionDao)2 FunctionDaoImpl (org.seasar.doma.it.dao.FunctionDaoImpl)2 ProcedureDao (org.seasar.doma.it.dao.ProcedureDao)2 ProcedureDaoImpl (org.seasar.doma.it.dao.ProcedureDaoImpl)2 JdbcException (org.seasar.doma.jdbc.JdbcException)2 BatchOptimisticLockException (org.seasar.doma.jdbc.BatchOptimisticLockException)1 UniqueConstraintException (org.seasar.doma.jdbc.UniqueConstraintException)1