use of org.seasar.doma.it.entity.CompKeyDepartment in project doma by domaframework.
the class AutoBatchInsertTest method testCompositeKey.
@Test
public void testCompositeKey(Config config) throws Exception {
CompKeyDepartmentDao dao = new CompKeyDepartmentDaoImpl(config);
CompKeyDepartment department = new CompKeyDepartment();
department.setDepartmentId1(99);
department.setDepartmentId2(99);
department.setDepartmentNo(99);
department.setDepartmentName("hoge");
CompKeyDepartment department2 = new CompKeyDepartment();
department2.setDepartmentId1(98);
department2.setDepartmentId2(98);
department2.setDepartmentNo(98);
department2.setDepartmentName("hoge");
int[] result = dao.insert(Arrays.asList(department, department2));
assertEquals(2, result.length);
assertEquals(1, result[0]);
assertEquals(1, result[1]);
assertEquals(Integer.valueOf(1), department.getVersion());
assertEquals(Integer.valueOf(1), department2.getVersion());
department = dao.selectById(Integer.valueOf(99), Integer.valueOf(99));
assertEquals(Integer.valueOf(99), department.getDepartmentId1());
assertEquals(Integer.valueOf(99), department.getDepartmentId2());
assertEquals(Integer.valueOf(99), department.getDepartmentNo());
assertEquals("hoge", department.getDepartmentName());
assertNull(department.getLocation());
assertEquals(Integer.valueOf(1), department.getVersion());
department = dao.selectById(98, 98);
assertEquals(Integer.valueOf(98), department.getDepartmentId1());
assertEquals(Integer.valueOf(98), department.getDepartmentId2());
assertEquals(Integer.valueOf(98), department.getDepartmentNo());
assertEquals("hoge", department.getDepartmentName());
assertNull(department.getLocation());
assertEquals(Integer.valueOf(1), department.getVersion());
}
use of org.seasar.doma.it.entity.CompKeyDepartment in project doma by domaframework.
the class AutoUpdateTest method testCompositeKey.
@Test
public void testCompositeKey(Config config) throws Exception {
CompKeyDepartmentDao dao = new CompKeyDepartmentDaoImpl(config);
CompKeyDepartment department = dao.selectById(1, 1);
department.setDepartmentNo(1);
department.setDepartmentName("hoge");
department.setVersion(1);
int result = dao.update(department);
assertEquals(1, result);
assertEquals(Integer.valueOf(2), department.getVersion());
department = dao.selectById(1, 1);
assertEquals(Integer.valueOf(1), department.getDepartmentId1());
assertEquals(Integer.valueOf(1), department.getDepartmentId2());
assertEquals(Integer.valueOf(1), department.getDepartmentNo());
assertEquals("hoge", department.getDepartmentName());
assertEquals("NEW YORK", department.getLocation());
assertEquals(Integer.valueOf(2), department.getVersion());
}
use of org.seasar.doma.it.entity.CompKeyDepartment in project doma by domaframework.
the class AutoBatchUpdateTest method testCompositeKey.
public void testCompositeKey(Config config) throws Exception {
CompKeyDepartmentDao dao = new CompKeyDepartmentDaoImpl(config);
CompKeyDepartment department = new CompKeyDepartment();
department.setDepartmentId1(1);
department.setDepartmentId2(1);
department.setDepartmentNo(1);
department.setDepartmentName("hoge");
department.setVersion(1);
CompKeyDepartment department2 = new CompKeyDepartment();
department2.setDepartmentId1(2);
department2.setDepartmentId2(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());
department = dao.selectById(1, 1);
assertEquals(Integer.valueOf(1), department.getDepartmentId1());
assertEquals(Integer.valueOf(1), department.getDepartmentId2());
assertEquals(Integer.valueOf(1), department.getDepartmentNo());
assertEquals("hoge", department.getDepartmentName());
assertNull(department.getLocation());
assertEquals(Integer.valueOf(2), department.getVersion());
department = dao.selectById(2, 2);
assertEquals(Integer.valueOf(2), department.getDepartmentId1());
assertEquals(Integer.valueOf(2), department.getDepartmentId2());
assertEquals(Integer.valueOf(2), department.getDepartmentNo());
assertEquals("foo", department.getDepartmentName());
assertNull(department.getLocation());
assertEquals(Integer.valueOf(2), department.getVersion());
}
use of org.seasar.doma.it.entity.CompKeyDepartment in project doma by domaframework.
the class AutoInsertTest method testCompositeKey.
@Test
public void testCompositeKey(Config config) throws Exception {
CompKeyDepartmentDao dao = new CompKeyDepartmentDaoImpl(config);
CompKeyDepartment department = new CompKeyDepartment();
department.setDepartmentId1(99);
department.setDepartmentId2(99);
department.setDepartmentNo(99);
department.setDepartmentName("hoge");
int result = dao.insert(department);
assertEquals(1, result);
assertEquals(Integer.valueOf(1), department.getVersion());
department = dao.selectById(99, 99);
assertEquals(Integer.valueOf(99), department.getDepartmentId1());
assertEquals(Integer.valueOf(99), department.getDepartmentId2());
assertEquals(Integer.valueOf(99), department.getDepartmentNo());
assertEquals("hoge", department.getDepartmentName());
assertNull(department.getLocation());
assertEquals(Integer.valueOf(1), department.getVersion());
}
Aggregations