use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class SqlFileUpdateTest 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.updateBySqlFile(department1);
try {
dao.updateBySqlFile(department2);
fail();
} catch (OptimisticLockException expected) {
}
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class SqlFileUpdateTest method testPopulates.
@Test
public void testPopulates(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);
int result = dao.updateBySqlFileWithPopulate(department);
assertEquals(1, result);
department = dao.selectById(1);
assertEquals(Integer.valueOf(1), department.getDepartmentId().getValue());
assertEquals("hoge", department.getDepartmentName());
assertEquals(Integer.valueOf(2), department.getVersion());
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class SqlFileUpdateTest 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);
int result = dao.updateBySqlFile(department);
assertEquals(1, result);
department = dao.selectById(1);
assertEquals(Integer.valueOf(1), department.getDepartmentId().getValue());
assertEquals("hoge", department.getDepartmentName());
assertEquals(Integer.valueOf(2), department.getVersion());
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class SqlFileUpdateTest method test_nonEntity.
@Test
public void test_nonEntity(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);
int result = dao.updateBySqlFile_nonEntity(new Identity<Department>(1), 1, "hoge", null, 1);
assertEquals(1, result);
department = dao.selectById(1);
assertEquals(Integer.valueOf(1), department.getDepartmentId().getValue());
assertEquals("hoge", department.getDepartmentName());
assertEquals(Integer.valueOf(2), department.getVersion());
}
use of org.seasar.doma.it.dao.DepartmentDao in project doma by domaframework.
the class SqlFileUpdateTest 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(1);
department2.setDepartmentName("foo");
dao.updateBySqlFile(department1);
int rows = dao.updateBySqlFile_ignoreVersion(department2);
assertEquals(0, rows);
}
Aggregations