use of org.seasar.doma.it.entity.Department 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) {
}
}
use of org.seasar.doma.it.entity.Department 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());
}
use of org.seasar.doma.it.entity.Department in project doma by domaframework.
the class SqlFileBatchInsertTest method test.
@Test
public void test(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");
Department department2 = new Department();
department2.setDepartmentId(new Identity<Department>(98));
department2.setDepartmentNo(98);
department2.setDepartmentName("foo");
int[] result = dao.insertBySqlFile(Arrays.asList(department, department2));
assertEquals(2, result.length);
assertEquals(1, result[0]);
assertEquals(1, result[1]);
department = dao.selectById(99);
assertEquals(Integer.valueOf(99), department.getDepartmentId().getValue());
assertEquals(Integer.valueOf(99), department.getDepartmentNo());
department = dao.selectById(98);
assertEquals(Integer.valueOf(98), department.getDepartmentId().getValue());
assertEquals(Integer.valueOf(98), department.getDepartmentNo());
}
use of org.seasar.doma.it.entity.Department in project doma by domaframework.
the class AutoBatchUpdateTest method testSqlExecutionSkip.
@Test
public void testSqlExecutionSkip(Config config) throws Exception {
DepartmentDao dao = new DepartmentDaoImpl(config);
int[] result = dao.update(new ArrayList<Department>());
assertEquals(0, result.length);
}
use of org.seasar.doma.it.entity.Department in project doma by domaframework.
the class AutoBatchUpdateTest 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.update_suppressOptimisticLockException(Arrays.asList(department2, department3));
}
Aggregations