use of org.seasar.doma.jdbc.OptimisticLockException in project doma by domaframework.
the class AutoBatchDeleteTest method testOptimisticLockException.
@Test
public void testOptimisticLockException(Config config) throws Exception {
EmployeeDao dao = new EmployeeDaoImpl(config);
Employee employee1 = dao.selectById(1);
employee1.setEmployeeName("hoge");
Employee employee2 = dao.selectById(2);
employee2.setEmployeeName("foo");
Employee employee3 = dao.selectById(1);
employee2.setEmployeeName("bar");
dao.delete(employee1);
try {
dao.delete(Arrays.asList(employee2, employee3));
fail();
} catch (OptimisticLockException expected) {
}
}
use of org.seasar.doma.jdbc.OptimisticLockException 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.jdbc.OptimisticLockException in project doma by domaframework.
the class UpdateCommandTest method testExecute_throwsOptimisticLockException.
@Test
public void testExecute_throwsOptimisticLockException() throws Exception {
Emp emp = new Emp();
emp.setId(10);
emp.setName("aaa");
emp.setVersion(100);
runtimeConfig.dataSource.connection.preparedStatement.updatedRows = 0;
AutoUpdateQuery<Emp> query = new AutoUpdateQuery<>(_Emp.getSingletonInternal());
query.setMethod(getClass().getDeclaredMethod(method.getName()));
query.setConfig(runtimeConfig);
query.setEntity(emp);
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
UpdateCommand command = new UpdateCommand(query);
try {
command.execute();
fail();
} catch (OptimisticLockException expected) {
}
}
use of org.seasar.doma.jdbc.OptimisticLockException 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.jdbc.OptimisticLockException in project doma by domaframework.
the class BatchUpdateCommandTest method testExecute_throwsOptimisticLockException.
@Test
public void testExecute_throwsOptimisticLockException() {
Emp emp = new Emp();
emp.setId(1);
emp.setName("hoge");
emp.setVersion(10);
runtimeConfig.dataSource.connection.preparedStatement.updatedRows = 0;
AutoBatchUpdateQuery<Emp> query = new AutoBatchUpdateQuery<>(_Emp.getSingletonInternal());
query.setMethod(method);
query.setConfig(runtimeConfig);
query.setEntities(Collections.singletonList(emp));
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
BatchUpdateCommand command = new BatchUpdateCommand(query);
try {
command.execute();
fail();
} catch (OptimisticLockException expected) {
}
}
Aggregations