Search in sources :

Example 1 with Department

use of org.seasar.doma.it.entity.Department in project doma by domaframework.

the class AutoFunctionTest method testResultSetAndUpdate.

@Test
@Run(unless = { Dbms.MYSQL, Dbms.SQLSERVER })
public void testResultSetAndUpdate(Config config) throws Exception {
    FunctionDao dao = new FunctionDaoImpl(config);
    List<Employee> result = dao.func_resultset_update(Integer.valueOf(1));
    assertEquals(13, result.size());
    DepartmentDao departmentDao = new DepartmentDaoImpl(config);
    Department department = departmentDao.selectById(Integer.valueOf(1));
    assertEquals("HOGE", department.getDepartmentName());
}
Also used : DepartmentDaoImpl(org.seasar.doma.it.dao.DepartmentDaoImpl) Department(org.seasar.doma.it.entity.Department) Employee(org.seasar.doma.it.entity.Employee) FunctionDaoImpl(org.seasar.doma.it.dao.FunctionDaoImpl) DepartmentDao(org.seasar.doma.it.dao.DepartmentDao) FunctionDao(org.seasar.doma.it.dao.FunctionDao) Test(org.junit.jupiter.api.Test) Run(org.seasar.doma.it.Run)

Example 2 with Department

use of org.seasar.doma.it.entity.Department in project doma by domaframework.

the class AutoInsertTest method test_UniqueConstraintException.

@Test
public void test_UniqueConstraintException(Config config) throws Exception {
    DepartmentDao dao = new DepartmentDaoImpl(config);
    Department department = new Department();
    department.setDepartmentId(new Identity<Department>(99));
    department.setDepartmentNo(99);
    department.setDepartmentName("hoge");
    int result = dao.insert(department);
    assertEquals(1, result);
    assertEquals(Integer.valueOf(1), department.getVersion());
    try {
        dao.insert(department);
        fail();
    } catch (UniqueConstraintException e) {
    }
}
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) UniqueConstraintException(org.seasar.doma.jdbc.UniqueConstraintException) DepartmentDao(org.seasar.doma.it.dao.DepartmentDao) CompKeyDepartmentDao(org.seasar.doma.it.dao.CompKeyDepartmentDao) Test(org.junit.jupiter.api.Test)

Example 3 with Department

use of org.seasar.doma.it.entity.Department in project doma by domaframework.

the class AutoInsertTest method testExcludeNull.

@Test
public void testExcludeNull(Config config) throws Exception {
    DepartmentDao dao = new DepartmentDaoImpl(config);
    Department department = new Department();
    department.setDepartmentId(new Identity<Department>(99));
    department.setDepartmentNo(99);
    department.setDepartmentName("hoge");
    int result = dao.insert_excludeNull(department);
    assertEquals(1, result);
    assertEquals(Integer.valueOf(1), department.getVersion());
    department = dao.selectById(Integer.valueOf(99));
    assertEquals(Integer.valueOf(99), department.getDepartmentId().getValue());
    assertEquals(Integer.valueOf(99), department.getDepartmentNo());
    assertEquals("hoge", department.getDepartmentName());
    assertEquals("TOKYO", department.getLocation().getValue());
    assertEquals(Integer.valueOf(1), 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 4 with Department

use of org.seasar.doma.it.entity.Department in project doma by domaframework.

the class AutoBatchUpdateTest method test.

@Test
public void test(Config config) throws Exception {
    DepartmentDao dao = new DepartmentDaoImpl(config);
    Department department = new Department();
    department.setDepartmentId(new Identity<Department>(1));
    department.setDepartmentNo(1);
    department.setDepartmentName("hoge");
    department.setVersion(1);
    Department department2 = new Department();
    department2.setDepartmentId(new Identity<Department>(2));
    department2.setDepartmentNo(2);
    department2.setDepartmentName("foo");
    department2.setVersion(1);
    int[] result = dao.update(Arrays.asList(department, department2));
    assertEquals(2, result.length);
    assertEquals(1, result[0]);
    assertEquals(1, result[1]);
    assertEquals(Integer.valueOf(2), department.getVersion());
    assertEquals(Integer.valueOf(2), department2.getVersion());
    department = dao.selectById(1);
    assertEquals(Integer.valueOf(1), department.getDepartmentId().getValue());
    assertEquals(Integer.valueOf(1), department.getDepartmentNo());
    assertEquals("hoge", department.getDepartmentName());
    assertNull(department.getLocation().getValue());
    assertEquals(Integer.valueOf(2), department.getVersion());
    department = dao.selectById(2);
    assertEquals(Integer.valueOf(2), department.getDepartmentId().getValue());
    assertEquals(Integer.valueOf(2), department.getDepartmentNo());
    assertEquals("foo", department.getDepartmentName());
    assertNull(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 5 with Department

use of org.seasar.doma.it.entity.Department in project doma by domaframework.

the class AutoBatchUpdateTest 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(2);
    department2.setDepartmentName("foo");
    Department department3 = dao.selectById(1);
    department3.setDepartmentName("bar");
    dao.update(department1);
    try {
        dao.update(Arrays.asList(department2, department3));
        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)

Aggregations

Test (org.junit.jupiter.api.Test)33 Department (org.seasar.doma.it.entity.Department)33 DepartmentDao (org.seasar.doma.it.dao.DepartmentDao)31 DepartmentDaoImpl (org.seasar.doma.it.dao.DepartmentDaoImpl)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)6 ArrayList (java.util.ArrayList)4 ProcedureDao (org.seasar.doma.it.dao.ProcedureDao)4 ProcedureDaoImpl (org.seasar.doma.it.dao.ProcedureDaoImpl)4 OptimisticLockException (org.seasar.doma.jdbc.OptimisticLockException)3 Run (org.seasar.doma.it.Run)2 FunctionDao (org.seasar.doma.it.dao.FunctionDao)2 FunctionDaoImpl (org.seasar.doma.it.dao.FunctionDaoImpl)2 JdbcException (org.seasar.doma.jdbc.JdbcException)2 BatchOptimisticLockException (org.seasar.doma.jdbc.BatchOptimisticLockException)1 Reference (org.seasar.doma.jdbc.Reference)1 UniqueConstraintException (org.seasar.doma.jdbc.UniqueConstraintException)1