use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class AutoUpdateTest method testIgnoreVersion.
@Test
public void testIgnoreVersion(Config config) throws Exception {
DepartmentDao dao = new DepartmentDaoImpl(config);
Department department = dao.selectById(1);
department.setDepartmentNo(1);
department.setDepartmentName("hoge");
department.setVersion(100);
int result = dao.update_ignoreVersion(department);
assertEquals(1, result);
assertEquals(Integer.valueOf(100), 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(100), department.getVersion());
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class AutoUpdateTest method testSqlExecutionSkip.
@Test
public void testSqlExecutionSkip(Config config) throws Exception {
DepartmentDao dao = new DepartmentDaoImpl(config);
Department department = dao.selectById(1);
int result = dao.update(department);
assertEquals(0, result);
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class SqlFileBatchUpdateTest 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.updateBySqlFile(Arrays.asList(department, department2));
assertEquals(2, result.length);
assertEquals(1, result[0]);
assertEquals(1, result[1]);
department = dao.selectById(1);
assertEquals(Integer.valueOf(1), department.getDepartmentId().getValue());
assertEquals("hoge", department.getDepartmentName());
assertEquals(Integer.valueOf(2), department.getVersion());
department = dao.selectById(2);
assertEquals(Integer.valueOf(2), department.getDepartmentId().getValue());
assertEquals("foo", department.getDepartmentName());
assertEquals(Integer.valueOf(2), department.getVersion());
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class SqlFileInsertTest 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");
int result = dao.insertBySqlFile(department);
assertEquals(1, result);
department = dao.selectById(Integer.valueOf(99));
assertEquals(Integer.valueOf(99), department.getDepartmentId().getValue());
assertEquals(Integer.valueOf(99), department.getDepartmentNo());
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class AutoBatchInsertTest method testIdNotAssigned.
@Test
public void testIdNotAssigned(Config config) throws Exception {
DepartmentDao dao = new DepartmentDaoImpl(config);
Department department = new Department();
department.setDepartmentNo(99);
department.setDepartmentName("hoge");
Department department2 = new Department();
department2.setDepartmentNo(98);
department2.setDepartmentName("hoge");
try {
dao.insert(Arrays.asList(department, department2));
fail();
} catch (JdbcException expected) {
assertEquals(Message.DOMA2020, expected.getMessageResource());
}
}
Aggregations