use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class AutoBatchUpdateTest method testIncludeVersion.
@Test
public void testIncludeVersion(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(100);
Department department2 = new Department();
department2.setDepartmentId(new Identity<Department>(2));
department2.setDepartmentNo(2);
department2.setDepartmentName("foo");
department2.setVersion(200);
int[] result = dao.update_ignoreVersion(Arrays.asList(department, department2));
assertEquals(2, result.length);
assertEquals(1, result[0]);
assertEquals(1, result[1]);
assertEquals(Integer.valueOf(100), department.getVersion());
assertEquals(Integer.valueOf(200), department2.getVersion());
department = dao.selectById(Integer.valueOf(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(100), department.getVersion());
department = dao.selectById(Integer.valueOf(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(200), department.getVersion());
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class AutoFunctionTest method testResultSetAndUpdate2.
@Test
@Run(unless = { Dbms.MYSQL, Dbms.SQLSERVER })
public void testResultSetAndUpdate2(Config config) throws Exception {
FunctionDao dao = new FunctionDaoImpl(config);
List<Employee> result = dao.func_resultset_update2(Integer.valueOf(1));
assertEquals(13, result.size());
DepartmentDao departmentDao = new DepartmentDaoImpl(config);
Department department = departmentDao.selectById(Integer.valueOf(1));
assertEquals("HOGE", department.getDepartmentName());
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class SqlFileBatchUpdateTest 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.updateBySqlFile(department1);
try {
dao.updateBySqlFile(Arrays.asList(department2, department3));
fail();
} catch (BatchOptimisticLockException expected) {
}
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class SqlFileBatchUpdateTest 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(2);
department2.setDepartmentName("foo");
Department department3 = dao.selectById(1);
department3.setDepartmentName("bar");
dao.update(department1);
dao.updateBySqlFile_suppressOptimisticLockException(Arrays.asList(department2, department3));
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class AutoProcedureTest method testResultSetAndUpdate.
@Test
public void testResultSetAndUpdate(Config config) throws Exception {
ProcedureDao dao = new ProcedureDaoImpl(config);
List<Employee> employees = new ArrayList<>();
dao.proc_resultset_update(employees, 1);
assertEquals(13, employees.size());
DepartmentDao departmentDao = new DepartmentDaoImpl(config);
Department department = departmentDao.selectById(1);
assertEquals("HOGE", department.getDepartmentName());
}
Aggregations